From 6e591d4b6418b4464270d80550a90ddf1e256b58 Mon Sep 17 00:00:00 2001 From: Dhwani Patel Date: Thu, 10 Aug 2023 14:47:11 -0600 Subject: [PATCH] Remove django_extensions from MAIN existing migrations --- .../administration/migrations/0001_initial.py | 8 +- .../migrations/0002_archivesspaceconfig.py | 5 +- .../src/main/migrations/0001_initial.py | 106 ++++++++++++------ ...3_archivesspacedipobjectresourcepairing.py | 17 ++- .../migrations/0006_levelofdescription.py | 5 +- .../main/migrations/0040_directory_model.py | 5 +- .../migrations/0059_siparrange_longblob.py | 7 +- .../migrations/0067_delete_workflow_models.py | 10 +- .../src/main/migrations/0070_index_jobs.py | 8 +- .../src/main/migrations/0077_uuid_fields.py | 33 ++++-- src/dashboard/src/main/models.py | 9 -- 11 files changed, 143 insertions(+), 70 deletions(-) diff --git a/src/dashboard/src/components/administration/migrations/0001_initial.py b/src/dashboard/src/components/administration/migrations/0001_initial.py index de57822ac7..390e63cdcd 100644 --- a/src/dashboard/src/components/administration/migrations/0001_initial.py +++ b/src/dashboard/src/components/administration/migrations/0001_initial.py @@ -1,3 +1,5 @@ +import uuid + import main.models from django.db import migrations from django.db import models @@ -13,13 +15,14 @@ class Migration(migrations.Migration): fields=[ ( "id", - main.models.UUIDPkField( + main.models.UUIDField( primary_key=True, db_column="pk", serialize=False, editable=False, max_length=36, blank=True, + default=uuid.uuid4, ), ), ("host", models.CharField(max_length=50)), @@ -51,13 +54,14 @@ class Migration(migrations.Migration): fields=[ ( "id", - main.models.UUIDPkField( + main.models.UUIDField( primary_key=True, db_column="pk", serialize=False, editable=False, max_length=36, blank=True, + default=uuid.uuid4, ), ), ("dictname", models.CharField(max_length=50)), diff --git a/src/dashboard/src/components/administration/migrations/0002_archivesspaceconfig.py b/src/dashboard/src/components/administration/migrations/0002_archivesspaceconfig.py index 5eaebc0581..76ec39c46e 100644 --- a/src/dashboard/src/components/administration/migrations/0002_archivesspaceconfig.py +++ b/src/dashboard/src/components/administration/migrations/0002_archivesspaceconfig.py @@ -1,3 +1,5 @@ +import uuid + import main.models from django.db import migrations from django.db import models @@ -22,13 +24,14 @@ class Migration(migrations.Migration): fields=[ ( "id", - main.models.UUIDPkField( + main.models.UUIDField( primary_key=True, db_column="pk", serialize=False, editable=False, max_length=36, blank=True, + default=uuid.uuid4, ), ), ( diff --git a/src/dashboard/src/main/migrations/0001_initial.py b/src/dashboard/src/main/migrations/0001_initial.py index 0659ca0f1e..a8a805c76b 100644 --- a/src/dashboard/src/main/migrations/0001_initial.py +++ b/src/dashboard/src/main/migrations/0001_initial.py @@ -1,4 +1,5 @@ -import django_extensions.db.fields +import uuid + import main.models from django.db import migrations from django.db import models @@ -18,7 +19,12 @@ class Migration(migrations.Migration): ), ( "sipuuid", - models.CharField(max_length=36, db_column="SIPUUID", blank=True), + main.models.UUIDField( + max_length=36, + db_column="SIPUUID", + blank=True, + default=uuid.uuid4, + ), ), ("resource", models.TextField(db_column="resource", blank=True)), ("target", models.TextField(db_column="target", blank=True)), @@ -185,13 +191,14 @@ class Migration(migrations.Migration): ), ( "event_id", - django_extensions.db.fields.UUIDField( + main.models.UUIDField( null=True, db_column="eventIdentifierUUID", editable=False, max_length=36, blank=True, unique=True, + default=uuid.uuid4, ), ), ("event_type", models.TextField(db_column="eventType", blank=True)), @@ -221,11 +228,12 @@ class Migration(migrations.Migration): fields=[ ( "uuid", - models.CharField( + main.models.UUIDField( max_length=36, serialize=False, primary_key=True, db_column="fileUUID", + default=uuid.uuid4, ), ), ("originallocation", models.TextField(db_column="originalLocation")), @@ -367,13 +375,14 @@ class Migration(migrations.Migration): fields=[ ( "jobuuid", - django_extensions.db.fields.UUIDField( + main.models.UUIDField( primary_key=True, db_column="jobUUID", serialize=False, editable=False, max_length=36, blank=True, + default=uuid.uuid4, ), ), ( @@ -391,7 +400,12 @@ class Migration(migrations.Migration): ), ), ("directory", models.TextField(blank=True)), - ("sipuuid", models.CharField(max_length=36, db_column="SIPUUID")), + ( + "sipuuid", + main.models.UUIDField( + max_length=36, db_column="SIPUUID", default=uuid.uuid4 + ), + ), ( "unittype", models.CharField(max_length=50, db_column="unitType", blank=True), @@ -422,13 +436,14 @@ class Migration(migrations.Migration): fields=[ ( "id", - main.models.UUIDPkField( + main.models.UUIDField( primary_key=True, db_column="pk", serialize=False, editable=False, max_length=36, blank=True, + default=uuid.uuid4, ), ), ( @@ -454,13 +469,14 @@ class Migration(migrations.Migration): fields=[ ( "id", - main.models.UUIDPkField( + main.models.UUIDField( primary_key=True, db_column="pk", serialize=False, editable=False, max_length=36, blank=True, + default=uuid.uuid4, ), ), ("description", models.TextField(db_column="description")), @@ -487,13 +503,14 @@ class Migration(migrations.Migration): fields=[ ( "id", - main.models.UUIDPkField( + main.models.UUIDField( primary_key=True, db_column="pk", serialize=False, editable=False, max_length=36, blank=True, + default=uuid.uuid4, ), ), ( @@ -517,13 +534,14 @@ class Migration(migrations.Migration): fields=[ ( "id", - main.models.UUIDPkField( + main.models.UUIDField( primary_key=True, db_column="pk", serialize=False, editable=False, max_length=36, blank=True, + default=uuid.uuid4, ), ), ( @@ -553,13 +571,14 @@ class Migration(migrations.Migration): fields=[ ( "id", - main.models.UUIDPkField( + main.models.UUIDField( primary_key=True, db_column="pk", serialize=False, editable=False, max_length=36, blank=True, + default=uuid.uuid4, ), ), ("exitcode", models.IntegerField(default=0, db_column="exitCode")), @@ -615,13 +634,14 @@ class Migration(migrations.Migration): fields=[ ( "id", - main.models.UUIDPkField( + main.models.UUIDField( primary_key=True, db_column="pk", serialize=False, editable=False, max_length=36, blank=True, + default=uuid.uuid4, ), ), ( @@ -1473,11 +1493,12 @@ class Migration(migrations.Migration): fields=[ ( "uuid", - models.CharField( + main.models.UUIDField( max_length=36, serialize=False, primary_key=True, db_column="sipUUID", + default=uuid.uuid4, ), ), ("createdtime", models.DateTimeField(db_column="createdTime")), @@ -1543,8 +1564,8 @@ class Migration(migrations.Migration): ("arrange_path", models.CharField(max_length=255)), ( "file_uuid", - django_extensions.db.fields.UUIDField( - default=None, + main.models.UUIDField( + default=uuid.uuid4, max_length=36, null=True, editable=False, @@ -1553,8 +1574,8 @@ class Migration(migrations.Migration): ), ( "transfer_uuid", - django_extensions.db.fields.UUIDField( - default=None, + main.models.UUIDField( + default=uuid.uuid4, max_length=36, null=True, editable=False, @@ -1572,13 +1593,14 @@ class Migration(migrations.Migration): fields=[ ( "id", - main.models.UUIDPkField( + main.models.UUIDField( primary_key=True, db_column="pk", serialize=False, editable=False, max_length=36, blank=True, + default=uuid.uuid4, ), ), ( @@ -1653,11 +1675,12 @@ class Migration(migrations.Migration): fields=[ ( "taskuuid", - models.CharField( + main.models.UUIDField( max_length=36, serialize=False, primary_key=True, db_column="taskUUID", + default=uuid.uuid4, ), ), ("createdtime", models.DateTimeField(db_column="createdTime")), @@ -1705,13 +1728,14 @@ class Migration(migrations.Migration): fields=[ ( "id", - main.models.UUIDPkField( + main.models.UUIDField( primary_key=True, db_column="pk", serialize=False, editable=False, max_length=36, blank=True, + default=uuid.uuid4, ), ), ( @@ -1749,13 +1773,14 @@ class Migration(migrations.Migration): fields=[ ( "id", - main.models.UUIDPkField( + main.models.UUIDField( primary_key=True, db_column="pk", serialize=False, editable=False, max_length=36, blank=True, + default=uuid.uuid4, ), ), ( @@ -1792,13 +1817,14 @@ class Migration(migrations.Migration): fields=[ ( "id", - main.models.UUIDPkField( + main.models.UUIDField( primary_key=True, db_column="pk", serialize=False, editable=False, max_length=36, blank=True, + default=uuid.uuid4, ), ), ("variable", models.TextField(blank=True)), @@ -1834,13 +1860,14 @@ class Migration(migrations.Migration): fields=[ ( "id", - main.models.UUIDPkField( + main.models.UUIDField( primary_key=True, db_column="pk", serialize=False, editable=False, max_length=36, blank=True, + default=uuid.uuid4, ), ), ("variable", models.TextField(blank=True)), @@ -1876,13 +1903,14 @@ class Migration(migrations.Migration): fields=[ ( "id", - main.models.UUIDPkField( + main.models.UUIDField( primary_key=True, db_column="pk", serialize=False, editable=False, max_length=36, blank=True, + default=uuid.uuid4, ), ), ("description", models.TextField(blank=True)), @@ -1910,13 +1938,14 @@ class Migration(migrations.Migration): fields=[ ( "id", - main.models.UUIDPkField( + main.models.UUIDField( primary_key=True, db_column="pk", serialize=False, editable=False, max_length=36, blank=True, + default=uuid.uuid4, ), ), ( @@ -1939,13 +1968,14 @@ class Migration(migrations.Migration): fields=[ ( "id", - main.models.UUIDPkField( + main.models.UUIDField( primary_key=True, db_column="pk", serialize=False, editable=False, max_length=36, blank=True, + default=uuid.uuid4, ), ), ( @@ -1972,11 +2002,12 @@ class Migration(migrations.Migration): fields=[ ( "uuid", - models.CharField( + main.models.UUIDField( max_length=36, serialize=False, primary_key=True, db_column="transferUUID", + default=uuid.uuid4, ), ), ("currentlocation", models.TextField(db_column="currentLocation")), @@ -2021,13 +2052,14 @@ class Migration(migrations.Migration): fields=[ ( "id", - main.models.UUIDPkField( + main.models.UUIDField( primary_key=True, db_column="pk", serialize=False, editable=False, max_length=36, blank=True, + default=uuid.uuid4, ), ), ( @@ -2061,13 +2093,14 @@ class Migration(migrations.Migration): fields=[ ( "id", - main.models.UUIDPkField( + main.models.UUIDField( primary_key=True, db_column="pk", serialize=False, editable=False, max_length=36, blank=True, + default=uuid.uuid4, ), ), ( @@ -2092,13 +2125,14 @@ class Migration(migrations.Migration): fields=[ ( "id", - main.models.UUIDPkField( + main.models.UUIDField( primary_key=True, db_column="pk", serialize=False, editable=False, max_length=36, blank=True, + default=uuid.uuid4, ), ), ( @@ -2115,13 +2149,14 @@ class Migration(migrations.Migration): fields=[ ( "id", - main.models.UUIDPkField( + main.models.UUIDField( primary_key=True, db_column="pk", serialize=False, editable=False, max_length=36, blank=True, + default=uuid.uuid4, ), ), ( @@ -2132,11 +2167,12 @@ class Migration(migrations.Migration): ), ( "unituuid", - models.CharField( + main.models.UUIDField( help_text="Semantically a foreign key to SIP or Transfer", max_length=36, null=True, db_column="unitUUID", + default=uuid.uuid4, ), ), ("variable", models.TextField(null=True, db_column="variable")), @@ -2172,13 +2208,14 @@ class Migration(migrations.Migration): fields=[ ( "id", - main.models.UUIDPkField( + main.models.UUIDField( primary_key=True, db_column="pk", serialize=False, editable=False, max_length=36, blank=True, + default=uuid.uuid4, ), ), ( @@ -2213,13 +2250,14 @@ class Migration(migrations.Migration): fields=[ ( "id", - main.models.UUIDPkField( + main.models.UUIDField( primary_key=True, db_column="pk", serialize=False, editable=False, max_length=36, blank=True, + default=uuid.uuid4, ), ), ("description", models.TextField(null=True)), diff --git a/src/dashboard/src/main/migrations/0003_archivesspacedipobjectresourcepairing.py b/src/dashboard/src/main/migrations/0003_archivesspacedipobjectresourcepairing.py index 4500b834f7..d25c6c3bdd 100644 --- a/src/dashboard/src/main/migrations/0003_archivesspacedipobjectresourcepairing.py +++ b/src/dashboard/src/main/migrations/0003_archivesspacedipobjectresourcepairing.py @@ -1,3 +1,6 @@ +import uuid + +import main.models from django.db import migrations from django.db import models @@ -14,8 +17,18 @@ class Migration(migrations.Migration): "id", models.AutoField(serialize=False, primary_key=True, db_column="pk"), ), - ("dipuuid", models.CharField(max_length=50, db_column="dipUUID")), - ("fileuuid", models.CharField(max_length=50, db_column="fileUUID")), + ( + "dipuuid", + main.models.UUIDField( + max_length=50, db_column="dipUUID", default=uuid.uuid4 + ), + ), + ( + "fileuuid", + main.models.UUIDField( + max_length=50, db_column="fileUUID", default=uuid.uuid4 + ), + ), ( "resourceid", models.CharField(max_length=150, db_column="resourceId"), diff --git a/src/dashboard/src/main/migrations/0006_levelofdescription.py b/src/dashboard/src/main/migrations/0006_levelofdescription.py index ae0eb7af89..d62dfd70e7 100644 --- a/src/dashboard/src/main/migrations/0006_levelofdescription.py +++ b/src/dashboard/src/main/migrations/0006_levelofdescription.py @@ -1,3 +1,5 @@ +import uuid + import main.models from django.db import migrations from django.db import models @@ -32,13 +34,14 @@ class Migration(migrations.Migration): fields=[ ( "id", - main.models.UUIDPkField( + main.models.UUIDField( primary_key=True, db_column="pk", serialize=False, editable=False, max_length=36, blank=True, + default=uuid.uuid4, ), ), ("name", models.CharField(max_length=1024)), diff --git a/src/dashboard/src/main/migrations/0040_directory_model.py b/src/dashboard/src/main/migrations/0040_directory_model.py index 5478386e03..b0a6f4b64a 100644 --- a/src/dashboard/src/main/migrations/0040_directory_model.py +++ b/src/dashboard/src/main/migrations/0040_directory_model.py @@ -1,3 +1,5 @@ +import uuid + import main.models from django.db import migrations from django.db import models @@ -228,11 +230,12 @@ class Migration(migrations.Migration): fields=[ ( "uuid", - models.CharField( + main.models.UUIDField( max_length=36, serialize=False, primary_key=True, db_column="directoryUUID", + default=uuid.uuid4, ), ), ( diff --git a/src/dashboard/src/main/migrations/0059_siparrange_longblob.py b/src/dashboard/src/main/migrations/0059_siparrange_longblob.py index 8287bd6535..32b21f4052 100644 --- a/src/dashboard/src/main/migrations/0059_siparrange_longblob.py +++ b/src/dashboard/src/main/migrations/0059_siparrange_longblob.py @@ -1,4 +1,5 @@ -import django_extensions.db.fields +import uuid + import main.models from django.db import migrations from django.db import OperationalError @@ -46,9 +47,9 @@ class Migration(migrations.Migration): migrations.AlterField( model_name="siparrange", name="file_uuid", - field=django_extensions.db.fields.UUIDField( + field=main.models.UUIDField( null=True, - default=None, + default=uuid.uuid4, editable=False, max_length=36, blank=True, diff --git a/src/dashboard/src/main/migrations/0067_delete_workflow_models.py b/src/dashboard/src/main/migrations/0067_delete_workflow_models.py index a90bc2294c..3229789151 100644 --- a/src/dashboard/src/main/migrations/0067_delete_workflow_models.py +++ b/src/dashboard/src/main/migrations/0067_delete_workflow_models.py @@ -1,4 +1,6 @@ -import django_extensions.db.fields +import uuid + +import main.models from django.db import migrations @@ -56,23 +58,25 @@ class Migration(migrations.Migration): migrations.AlterField( model_name="job", name="microservicechainlink", - field=django_extensions.db.fields.UUIDField( + field=main.models.UUIDField( max_length=36, null=True, editable=False, db_column="MicroServiceChainLinksPK", blank=True, + default=uuid.uuid4, ), ), migrations.AlterField( model_name="unitvariable", name="microservicechainlink", - field=django_extensions.db.fields.UUIDField( + field=main.models.UUIDField( max_length=36, null=True, editable=False, db_column="microServiceChainLink", blank=True, + default=uuid.uuid4, ), ), migrations.DeleteModel(name="MicroServiceChain"), diff --git a/src/dashboard/src/main/migrations/0070_index_jobs.py b/src/dashboard/src/main/migrations/0070_index_jobs.py index 10ba65f7d9..11e630fb43 100644 --- a/src/dashboard/src/main/migrations/0070_index_jobs.py +++ b/src/dashboard/src/main/migrations/0070_index_jobs.py @@ -1,5 +1,7 @@ +import uuid + +import main.models from django.db import migrations -from django.db import models class Migration(migrations.Migration): @@ -10,7 +12,9 @@ class Migration(migrations.Migration): migrations.AlterField( model_name="job", name="sipuuid", - field=models.CharField(max_length=36, db_column="SIPUUID", db_index=True), + field=main.models.UUIDField( + max_length=36, db_column="SIPUUID", db_index=True, default=uuid.uuid4 + ), ), migrations.AlterIndexTogether( name="job", diff --git a/src/dashboard/src/main/migrations/0077_uuid_fields.py b/src/dashboard/src/main/migrations/0077_uuid_fields.py index 5b8d617f70..d016ccfb6c 100644 --- a/src/dashboard/src/main/migrations/0077_uuid_fields.py +++ b/src/dashboard/src/main/migrations/0077_uuid_fields.py @@ -1,5 +1,7 @@ """Migration generated by Django 1.11.29.""" -import django_extensions.db.fields +import uuid + +import main.models from django.db import migrations @@ -11,36 +13,43 @@ class Migration(migrations.Migration): migrations.AlterField( model_name="event", name="event_id", - field=django_extensions.db.fields.UUIDField( - auto=False, db_column="eventIdentifierUUID", null=True, unique=True + field=main.models.UUIDField( + db_column="eventIdentifierUUID", + null=True, + unique=True, + default=uuid.uuid4, ), ), migrations.AlterField( model_name="job", name="microservicechainlink", - field=django_extensions.db.fields.UUIDField( - auto=False, blank=True, db_column="MicroServiceChainLinksPK", null=True + field=main.models.UUIDField( + blank=True, + db_column="MicroServiceChainLinksPK", + null=True, + default=uuid.uuid4, ), ), migrations.AlterField( model_name="siparrange", name="file_uuid", - field=django_extensions.db.fields.UUIDField( - auto=False, blank=True, default=None, null=True, unique=True + field=main.models.UUIDField( + blank=True, default=uuid.uuid4, null=True, unique=True ), ), migrations.AlterField( model_name="siparrange", name="transfer_uuid", - field=django_extensions.db.fields.UUIDField( - auto=False, blank=True, default=None, null=True - ), + field=main.models.UUIDField(blank=True, default=uuid.uuid4, null=True), ), migrations.AlterField( model_name="unitvariable", name="microservicechainlink", - field=django_extensions.db.fields.UUIDField( - auto=False, blank=True, db_column="microServiceChainLink", null=True + field=main.models.UUIDField( + blank=True, + db_column="microServiceChainLink", + null=True, + default=uuid.uuid4, ), ), ] diff --git a/src/dashboard/src/main/models.py b/src/dashboard/src/main/models.py index 4bb75c73ec..b6b1ff3169 100644 --- a/src/dashboard/src/main/models.py +++ b/src/dashboard/src/main/models.py @@ -31,7 +31,6 @@ from django.db.models.signals import post_save from django.dispatch import receiver from django.utils.translation import ugettext_lazy as _ -from django_extensions.db import fields from version import get_preservation_system_identifier # Core Django, alphabetical by import source @@ -83,14 +82,6 @@ def get_db_prep_value(self, value, connection, prepared=False): return str(value) -class UUIDPkField(fields.UUIDField): - def __init__(self, *args, **kwargs): - kwargs.setdefault("max_length", 36) - kwargs["primary_key"] = True - kwargs["db_column"] = "pk" - super().__init__(*args, **kwargs) - - class BlobTextField(models.TextField): """ Text field backed by `longblob` instead of `longtext`.