1
0
mirror of https://github.com/etesync/server synced 2024-12-02 21:48:21 +00:00
etesync-server/django_etesync/migrations/0029_auto_20200312_1849.py

32 lines
974 B
Python
Raw Normal View History

2020-03-12 19:02:27 +00:00
# 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),
]