| 1 | # Generated by Django 2.0.6 on 2018-06-12 12:19
|
|---|
| 2 | from django.db import migrations, models
|
|---|
| 3 | import uuid
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 | from common.migration_utils import CustomMigration
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 | def populate_and_match_uuids(apps, schema_editor):
|
|---|
| 10 | ExampleLayout = apps.get_model('vario', 'ExampleLayout')
|
|---|
| 11 | LayoutField = apps.get_model('vario', 'LayoutField')
|
|---|
| 12 |
|
|---|
| 13 | for layout in ExampleLayout.objects.all():
|
|---|
| 14 | layout.uuid = uuid.uuid4()
|
|---|
| 15 | layout.save()
|
|---|
| 16 |
|
|---|
| 17 | for field in LayoutField.objects.all():
|
|---|
| 18 | field.uuid = uuid.uuid4()
|
|---|
| 19 | field.temp_layout = field.layout.uuid
|
|---|
| 20 | field.save()
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 | class Migration(CustomMigration):
|
|---|
| 24 |
|
|---|
| 25 | dependencies = [
|
|---|
| 26 | ('vario', '0025_custom_layouts_changes'),
|
|---|
| 27 | ]
|
|---|
| 28 |
|
|---|
| 29 | operations = [
|
|---|
| 30 | migrations.RunPython(
|
|---|
| 31 | code=populate_and_match_uuids,
|
|---|
| 32 | reverse_code=migrations.RunPython.noop
|
|---|
| 33 | ),
|
|---|
| 34 | ]
|
|---|