Commit 16b3f1e4 authored by Jason Robinson's avatar Jason Robinson

Fix Tag.uuid migration

Split into 3 parts to first introduce as null, then fill,
then make not null.
parent 684e504c
# Generated by Django 2.0.8 on 2019-02-04 19:34
# Generated by Django 2.0.8 on 2019-02-15 23:23
from django.db import migrations, models
import uuid
class Migration(migrations.Migration):
......@@ -14,6 +13,6 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='tag',
name='uuid',
field=models.UUIDField(default=uuid.uuid4, editable=False, unique=True),
field=models.UUIDField(editable=False, null=True, unique=True),
),
]
# Generated by Django 2.0.8 on 2019-02-15 23:23
import uuid
from django.db import migrations
from django.db.migrations import RunPython
def forward(apps, schema_editor):
Tag = apps.get_model("content", "Tag")
for tag in Tag.objects.iterator():
if not tag.uuid:
Tag.objects.filter(id=tag.id).update(uuid=uuid.uuid4())
class Migration(migrations.Migration):
dependencies = [
('content', '0033_tag_uuid'),
]
operations = [
RunPython(forward, RunPython.noop)
]
# Generated by Django 2.0.8 on 2019-02-16 00:24
from django.db import migrations, models
import uuid
class Migration(migrations.Migration):
dependencies = [
('content', '0034_fill_tag_uuid'),
]
operations = [
migrations.AlterField(
model_name='tag',
name='uuid',
field=models.UUIDField(default=uuid.uuid4, editable=False, unique=True),
),
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment