summaryrefslogtreecommitdiff
path: root/archaeological_warehouse/migrations/0117_migrate_created.py
blob: 8bf1256279307b24f8e6086ee3f2c0d1a8b7e470 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Generated by Django 2.2.24 on 2023-01-30 17:20

from django.db import migrations
from ishtar_common.utils_migrations import migrate_created_field


def migrate_created(apps, __):
    app_name = "archaeological_warehouse"
    model_names = [
        "Warehouse",
        "Container",
    ]
    migrate_created_field(apps, app_name, model_names)


def migrate_history_date(apps, __):
    app_name = "archaeological_warehouse"
    model_name = "Container"
    model = apps.get_model(app_name, model_name)
    for item in model.objects.all():
        item.created = item.history_date_deprecated
        item.skip_history_when_saving = True
        item.save()


class Migration(migrations.Migration):

    dependencies = [
        ('archaeological_warehouse', '0116_auto_20230202_1633'),
    ]

    operations = [
        migrations.RunPython(migrate_created),
        migrations.RunPython(migrate_history_date)
    ]