From 82fec4fd416a64f5a64b3b4363033d2b9380de44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Fri, 8 May 2020 10:20:00 +0200 Subject: [PATCH] switch to native postgresql json field (#42647) --- .../migrations/0004_wcs_batches.py | 4 ++-- .../migrations/0005_text_to_jsonb.py | 17 +++++++++++++++++ passerelle_reunion_fsn/models.py | 4 ++-- setup.py | 1 - 4 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 passerelle_reunion_fsn/migrations/0005_text_to_jsonb.py diff --git a/passerelle_reunion_fsn/migrations/0004_wcs_batches.py b/passerelle_reunion_fsn/migrations/0004_wcs_batches.py index cbe2574..f493f51 100644 --- a/passerelle_reunion_fsn/migrations/0004_wcs_batches.py +++ b/passerelle_reunion_fsn/migrations/0004_wcs_batches.py @@ -3,8 +3,8 @@ from __future__ import unicode_literals from django.db import migrations, models +import django.contrib.postgres.fields.jsonb import django.db.models.deletion -import jsonfield.fields import passerelle_reunion_fsn.models @@ -45,7 +45,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name='fsnreunionconnector', name='wcs_options', - field=jsonfield.fields.JSONField(blank=True, null=True), + field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, null=True), ), migrations.AddField( model_name='batch', diff --git a/passerelle_reunion_fsn/migrations/0005_text_to_jsonb.py b/passerelle_reunion_fsn/migrations/0005_text_to_jsonb.py new file mode 100644 index 0000000..f275271 --- /dev/null +++ b/passerelle_reunion_fsn/migrations/0005_text_to_jsonb.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations + +from passerelle.utils.db import EnsureJsonbType + + +class Migration(migrations.Migration): + + dependencies = [ + ('passerelle_reunion_fsn', '0004_wcs_batches'), + ] + + operations = [ + EnsureJsonbType(model_name='FSNReunionConnector', field_name='wcs_options'), + ] diff --git a/passerelle_reunion_fsn/models.py b/passerelle_reunion_fsn/models.py index a148ef8..79968c7 100644 --- a/passerelle_reunion_fsn/models.py +++ b/passerelle_reunion_fsn/models.py @@ -25,6 +25,7 @@ import os.path import tempfile from django.conf import settings +from django.contrib.postgres.fields import JSONField from django.core.files import File from django.core.urlresolvers import reverse from django.db import models, transaction @@ -34,7 +35,6 @@ from django.utils.dateparse import parse_date, parse_datetime from django.utils.encoding import force_str, force_text, smart_text from django.utils.six.moves.urllib import parse as urlparse from django.utils.translation import ugettext_lazy as _ -import jsonfield from passerelle.base.models import BaseResource from passerelle.base.signature import sign_url from passerelle.utils.api import endpoint @@ -121,7 +121,7 @@ class FSNReunionConnector(BaseResource): help_text=_('Region identifier for this case') ) wcs_form_slug = models.CharField(max_length=256, blank=True, verbose_name=_('WCS form slug')) - wcs_options = jsonfield.JSONField(null=True, blank=True) + wcs_options = JSONField(null=True, blank=True) def hourly(self): self.logger.info('start fetch dossier') diff --git a/setup.py b/setup.py index 1fdb33a..9f0feb0 100644 --- a/setup.py +++ b/setup.py @@ -44,7 +44,6 @@ setup( author_email='ecazenave@entrouvert.com', packages=find_packages(), install_requires=[ - 'django-jsonfield', 'unicodecsv' ], cmdclass={