Skip to content

Commit

Permalink
Remove django_extensions from FPR existing migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
replaceafill committed Aug 10, 2023
1 parent d408df0 commit 799e271
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
32 changes: 21 additions & 11 deletions src/dashboard/src/fpr/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import uuid

import autoslug.fields
import django_extensions.db.fields
import main.models
from django.db import migrations
from django.db import models


class Migration(migrations.Migration):

dependencies = []

operations = [
Expand Down Expand Up @@ -271,12 +272,13 @@ class Migration(migrations.Migration):
),
(
"uuid",
django_extensions.db.fields.UUIDField(
main.models.UUIDField(
help_text="Unique identifier",
unique=True,
max_length=36,
editable=False,
blank=True,
default=uuid.uuid4,
),
),
(
Expand All @@ -302,12 +304,13 @@ class Migration(migrations.Migration):
),
(
"uuid",
django_extensions.db.fields.UUIDField(
main.models.UUIDField(
help_text="Unique identifier",
unique=True,
max_length=36,
editable=False,
blank=True,
default=uuid.uuid4,
),
),
(
Expand Down Expand Up @@ -335,12 +338,13 @@ class Migration(migrations.Migration):
("lastmodified", models.DateTimeField(auto_now_add=True)),
(
"uuid",
django_extensions.db.fields.UUIDField(
main.models.UUIDField(
help_text="Unique identifier",
unique=True,
max_length=36,
editable=False,
blank=True,
default=uuid.uuid4,
),
),
("version", models.CharField(max_length=10, null=True, blank=True)),
Expand Down Expand Up @@ -400,12 +404,13 @@ class Migration(migrations.Migration):
("lastmodified", models.DateTimeField(auto_now_add=True)),
(
"uuid",
django_extensions.db.fields.UUIDField(
main.models.UUIDField(
help_text="Unique identifier",
unique=True,
max_length=36,
editable=False,
blank=True,
default=uuid.uuid4,
),
),
("description", models.CharField(max_length=256)),
Expand Down Expand Up @@ -492,12 +497,13 @@ class Migration(migrations.Migration):
("lastmodified", models.DateTimeField(auto_now_add=True)),
(
"uuid",
django_extensions.db.fields.UUIDField(
main.models.UUIDField(
help_text="Unique identifier",
unique=True,
max_length=36,
editable=False,
blank=True,
default=uuid.uuid4,
),
),
(
Expand Down Expand Up @@ -563,12 +569,13 @@ class Migration(migrations.Migration):
),
(
"uuid",
django_extensions.db.fields.UUIDField(
main.models.UUIDField(
help_text="Unique identifier",
unique=True,
max_length=36,
editable=False,
blank=True,
default=uuid.uuid4,
),
),
(
Expand Down Expand Up @@ -598,12 +605,13 @@ class Migration(migrations.Migration):
("lastmodified", models.DateTimeField(auto_now_add=True)),
(
"uuid",
django_extensions.db.fields.UUIDField(
main.models.UUIDField(
help_text="Unique identifier",
unique=True,
max_length=36,
editable=False,
blank=True,
default=uuid.uuid4,
),
),
(
Expand Down Expand Up @@ -671,12 +679,13 @@ class Migration(migrations.Migration):
("lastmodified", models.DateTimeField(auto_now_add=True)),
(
"uuid",
django_extensions.db.fields.UUIDField(
main.models.UUIDField(
help_text="Unique identifier",
unique=True,
max_length=36,
editable=False,
blank=True,
default=uuid.uuid4,
),
),
("command_output", models.TextField()),
Expand Down Expand Up @@ -722,12 +731,13 @@ class Migration(migrations.Migration):
),
(
"uuid",
django_extensions.db.fields.UUIDField(
main.models.UUIDField(
help_text="Unique identifier",
unique=True,
max_length=36,
editable=False,
blank=True,
default=uuid.uuid4,
),
),
(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import uuid

from django.db import migrations


Expand Down Expand Up @@ -54,7 +56,7 @@ def data_migration(apps, schema_editor):
FPRule = apps.get_model("fpr", "FPRule")

# Skip if the existing command is not replace_command_uuid.
replace_command_uuid = "3bd47271-a3fa-4627-be97-9f7f69ddeefd"
replace_command_uuid = uuid.UUID("3bd47271-a3fa-4627-be97-9f7f69ddeefd")
rule = FPRule.objects.get(enabled=True, purpose="default_thumbnail")
if rule.command_id != replace_command_uuid:
return
Expand Down
2 changes: 2 additions & 0 deletions src/dashboard/src/main/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@

class UUIDField(models.UUIDField):
"""Customize Django's UUIDField default behaviour.
This subclass maintains backward compatibility with django-extension's
UUIDField data to avoid data migrations.
By default, Django's UUIDField stores UUIDs as CHAR(32) columns with
hexadecimal digits only. This subclass stores the hyphens as well using
VARCHAR(36) columns instead.
Expand Down

0 comments on commit 799e271

Please sign in to comment.