summaryrefslogtreecommitdiff
path: root/ishtar_common/migrations/0081_recreate_m2m_history.py
blob: e26a3f185bf197a2cbb46d508d3d120c61f61637 (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
# -*- coding: utf-8 -*-
# Generated by Django 1.11.10 on 2019-01-16 11:16
from __future__ import unicode_literals

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


def recreate_m2m_migrations(apps, schema_editor):
    from archaeological_context_records.models import ContextRecord
    from archaeological_files.models import File
    from archaeological_finds.models import Find, Treatment
    from archaeological_operations.models import Operation, ArchaeologicalSite
    history_models = [
        ContextRecord, File, Find, Treatment, Operation, ArchaeologicalSite
    ]
    for model in history_models:
        for item in model.objects.all():
            m2m_historization_init(item)


class Migration(migrations.Migration):

    dependencies = [
        ('ishtar_common', '0080_auto_20190111_1755'),
        ('archaeological_context_records', '0036_auto_20190111_1755'),
        ('archaeological_files', '0017_auto_20190111_1755'),
        ('archaeological_finds', '0055_auto_20190111_1755'),
        ('archaeological_operations', '0044_auto_20190111_1755')
    ]

    operations = [
        migrations.RunPython(recreate_m2m_migrations)
    ]