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.
|
|
|
# Generated by Django 3.0.3 on 2020-03-12 18:49
|
|
|
|
|
|
|
|
from django.db import migrations
|
|
|
|
from django.utils.crypto import get_random_string
|
|
|
|
|
|
|
|
|
|
|
|
def generate_rev_uid(length=32):
|
|
|
|
return get_random_string(length)
|
|
|
|
|
|
|
|
|
|
|
|
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),
|
|
|
|
]
|