You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
974 B
Python
32 lines
974 B
Python
5 years ago
|
# Generated by Django 3.0.3 on 2020-03-12 18:49
|
||
|
|
||
|
from django.db import migrations
|
||
|
from django_etesync.serializers import generate_rev_uid
|
||
|
|
||
|
|
||
|
def add_collection_main_item(apps, schema_editor):
|
||
|
Collection = apps.get_model('django_etesync', 'Collection')
|
||
|
CollectionItem = apps.get_model('django_etesync', 'CollectionItem')
|
||
|
CollectionItemRevision = apps.get_model('django_etesync', 'CollectionItemRevision')
|
||
|
|
||
|
for col in Collection.objects.all():
|
||
|
main_item = CollectionItem.objects.create(uid=None, encryptionKey=None, version=col.version, collection=col)
|
||
|
col.mainItem = main_item
|
||
|
col.save()
|
||
|
|
||
|
CollectionItemRevision.objects.create(
|
||
|
uid=generate_rev_uid(),
|
||
|
hmac='hmac-hash',
|
||
|
item=main_item)
|
||
|
|
||
|
|
||
|
class Migration(migrations.Migration):
|
||
|
|
||
|
dependencies = [
|
||
|
('django_etesync', '0028_auto_20200312_1819'),
|
||
|
]
|
||
|
|
||
|
operations = [
|
||
|
migrations.RunPython(add_collection_main_item),
|
||
|
]
|