2
0
Эх сурвалжийг харах

Change Postgres-specific JSONField to stock Django field

Jeremy Stretch 5 жил өмнө
parent
commit
21a750e8ec

+ 23 - 0
netbox/dcim/migrations/0114_update_jsonfield.py

@@ -0,0 +1,23 @@
+# Generated by Django 3.1b1 on 2020-07-16 16:01
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('dcim', '0113_nullbooleanfield_to_booleanfield'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='device',
+            name='local_context_data',
+            field=models.JSONField(blank=True, null=True),
+        ),
+        migrations.AlterField(
+            model_name='platform',
+            name='napalm_args',
+            field=models.JSONField(blank=True, null=True),
+        ),
+    ]

+ 2 - 2
netbox/dcim/models/__init__.py

@@ -6,7 +6,7 @@ from django.conf import settings
 from django.contrib.auth.models import User
 from django.contrib.auth.models import User
 from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
 from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
 from django.contrib.contenttypes.models import ContentType
 from django.contrib.contenttypes.models import ContentType
-from django.contrib.postgres.fields import ArrayField, JSONField
+from django.contrib.postgres.fields import ArrayField
 from django.core.exceptions import ObjectDoesNotExist, ValidationError
 from django.core.exceptions import ObjectDoesNotExist, ValidationError
 from django.core.validators import MaxValueValidator, MinValueValidator
 from django.core.validators import MaxValueValidator, MinValueValidator
 from django.db import models
 from django.db import models
@@ -1280,7 +1280,7 @@ class Platform(ChangeLoggedModel):
         verbose_name='NAPALM driver',
         verbose_name='NAPALM driver',
         help_text='The name of the NAPALM driver to use when interacting with devices'
         help_text='The name of the NAPALM driver to use when interacting with devices'
     )
     )
-    napalm_args = JSONField(
+    napalm_args = models.JSONField(
         blank=True,
         blank=True,
         null=True,
         null=True,
         verbose_name='NAPALM arguments',
         verbose_name='NAPALM arguments',

+ 28 - 0
netbox/extras/migrations/0046_update_jsonfield.py

@@ -0,0 +1,28 @@
+# Generated by Django 3.1b1 on 2020-07-16 16:01
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('extras', '0045_configcontext_changelog'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='configcontext',
+            name='data',
+            field=models.JSONField(),
+        ),
+        migrations.AlterField(
+            model_name='jobresult',
+            name='data',
+            field=models.JSONField(blank=True, null=True),
+        ),
+        migrations.AlterField(
+            model_name='objectchange',
+            name='object_data',
+            field=models.JSONField(editable=False),
+        ),
+    ]

+ 1 - 2
netbox/extras/models/change_logging.py

@@ -1,7 +1,6 @@
 from django.contrib.auth.models import User
 from django.contrib.auth.models import User
 from django.contrib.contenttypes.fields import GenericForeignKey
 from django.contrib.contenttypes.fields import GenericForeignKey
 from django.contrib.contenttypes.models import ContentType
 from django.contrib.contenttypes.models import ContentType
-from django.contrib.postgres.fields import JSONField
 from django.db import models
 from django.db import models
 from django.urls import reverse
 from django.urls import reverse
 
 
@@ -104,7 +103,7 @@ class ObjectChange(models.Model):
         max_length=200,
         max_length=200,
         editable=False
         editable=False
     )
     )
-    object_data = JSONField(
+    object_data = models.JSONField(
         editable=False
         editable=False
     )
     )
 
 

+ 3 - 4
netbox/extras/models/models.py

@@ -5,7 +5,6 @@ from collections import OrderedDict
 from django.contrib.auth.models import User
 from django.contrib.auth.models import User
 from django.contrib.contenttypes.fields import GenericForeignKey
 from django.contrib.contenttypes.fields import GenericForeignKey
 from django.contrib.contenttypes.models import ContentType
 from django.contrib.contenttypes.models import ContentType
-from django.contrib.postgres.fields import JSONField
 from django.core.validators import ValidationError
 from django.core.validators import ValidationError
 from django.db import models
 from django.db import models
 from django.http import HttpResponse
 from django.http import HttpResponse
@@ -499,7 +498,7 @@ class ConfigContext(ChangeLoggedModel):
         related_name='+',
         related_name='+',
         blank=True
         blank=True
     )
     )
-    data = JSONField()
+    data = models.JSONField()
 
 
     objects = ConfigContextQuerySet.as_manager()
     objects = ConfigContextQuerySet.as_manager()
 
 
@@ -526,7 +525,7 @@ class ConfigContextModel(models.Model):
     A model which includes local configuration context data. This local data will override any inherited data from
     A model which includes local configuration context data. This local data will override any inherited data from
     ConfigContexts.
     ConfigContexts.
     """
     """
-    local_context_data = JSONField(
+    local_context_data = models.JSONField(
         blank=True,
         blank=True,
         null=True,
         null=True,
     )
     )
@@ -627,7 +626,7 @@ class JobResult(models.Model):
         choices=JobResultStatusChoices,
         choices=JobResultStatusChoices,
         default=JobResultStatusChoices.STATUS_PENDING
         default=JobResultStatusChoices.STATUS_PENDING
     )
     )
-    data = JSONField(
+    data = models.JSONField(
         null=True,
         null=True,
         blank=True
         blank=True
     )
     )

+ 23 - 0
netbox/users/migrations/0010_update_jsonfield.py

@@ -0,0 +1,23 @@
+# Generated by Django 3.1b1 on 2020-07-16 16:01
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('users', '0009_replicate_permissions'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='objectpermission',
+            name='constraints',
+            field=models.JSONField(blank=True, null=True),
+        ),
+        migrations.AlterField(
+            model_name='userconfig',
+            name='data',
+            field=models.JSONField(default=dict),
+        ),
+    ]

+ 3 - 3
netbox/users/models.py

@@ -3,7 +3,7 @@ import os
 
 
 from django.contrib.auth.models import Group, User
 from django.contrib.auth.models import Group, User
 from django.contrib.contenttypes.models import ContentType
 from django.contrib.contenttypes.models import ContentType
-from django.contrib.postgres.fields import ArrayField, JSONField
+from django.contrib.postgres.fields import ArrayField
 from django.core.validators import MinLengthValidator
 from django.core.validators import MinLengthValidator
 from django.db import models
 from django.db import models
 from django.db.models.signals import post_save
 from django.db.models.signals import post_save
@@ -56,7 +56,7 @@ class UserConfig(models.Model):
         on_delete=models.CASCADE,
         on_delete=models.CASCADE,
         related_name='config'
         related_name='config'
     )
     )
-    data = JSONField(
+    data = models.JSONField(
         default=dict
         default=dict
     )
     )
 
 
@@ -265,7 +265,7 @@ class ObjectPermission(models.Model):
         base_field=models.CharField(max_length=30),
         base_field=models.CharField(max_length=30),
         help_text="The list of actions granted by this permission"
         help_text="The list of actions granted by this permission"
     )
     )
-    constraints = JSONField(
+    constraints = models.JSONField(
         blank=True,
         blank=True,
         null=True,
         null=True,
         help_text="Queryset filter matching the applicable objects of the selected type(s)"
         help_text="Queryset filter matching the applicable objects of the selected type(s)"

+ 18 - 0
netbox/virtualization/migrations/0017_update_jsonfield.py

@@ -0,0 +1,18 @@
+# Generated by Django 3.1b1 on 2020-07-16 16:01
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('virtualization', '0016_replicate_interfaces'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='virtualmachine',
+            name='local_context_data',
+            field=models.JSONField(blank=True, null=True),
+        ),
+    ]