# Generated by Django 2.2.10 on 2020-04-14 11:38

from django.db import migrations
from main.models import Casebook

def copy_old_dates(app, schema):
    update_cbs = []
    for casebook in Casebook.objects.select_related('old_casebook').all():
        if casebook.old_casebook:
            casebook.created_at = casebook.old_casebook.created_at
            update_cbs.append(casebook)
    Casebook.objects.bulk_update(update_cbs, ['created_at'])

class Migration(migrations.Migration):

    dependencies = [
        ('main', '0051_auto_20200407_1714'),
    ]

    operations = [
        migrations.RunPython(copy_old_dates, migrations.RunPython.noop)
    ]

Migrate creation date to new casebooks