Ticket #29496: 0026_populate_and_match_layout_uuids.py

File 0026_populate_and_match_layout_uuids.py, 851 bytes (added by Peter Levi, 6 years ago)

migration 2 - data changes to populate the new uuid fields and references

Line 
1# Generated by Django 2.0.6 on 2018-06-12 12:19
2from django.db import migrations, models
3import uuid
4
5
6from common.migration_utils import CustomMigration
7
8
9def 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
23class 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 ]
Back to Top