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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# -*- coding: utf-8 -*-
# Generated by Django 1.11.27 on 2020-04-08 18:23
from django.db import migrations, models
import archaeological_warehouse.models
import archaeological_finds.models
def migrate_to_collections(apps, schema_editor):
Container = apps.get_model('archaeological_warehouse', 'Container')
for c in Container.objects.all():
if c.responsible_id and c.location_id != c.responsible_id:
for find in c.finds_ref.all():
find.collection = c.responsible
find.skip_history_when_saving = True
find._no_move = True
find.save()
class Migration(migrations.Migration):
dependencies = [
('archaeological_warehouse', '0102_auto_20200408_1823'),
]
operations = [
migrations.RunSQL(
archaeological_finds.models.FindInsideContainer.DELETE_SQL),
migrations.RunSQL(
archaeological_warehouse.models.ContainerTree.DELETE_SQL),
migrations.RunSQL(
archaeological_warehouse.models.ContainerTree.CREATE_SQL),
migrations.RunSQL(
archaeological_finds.models.FindInsideContainer.CREATE_SQL),
migrations.RunPython(migrate_to_collections),
migrations.CreateModel(
name='ContainerTree',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True,
serialize=False, verbose_name='ID')),
],
options={
'db_table': 'containers_tree',
'managed': False,
},
),
migrations.AlterUniqueTogether(
name='containerlocalisation',
unique_together=set([]),
),
]
|