diff options
Diffstat (limited to 'archaeological_context_records/migrations')
| -rw-r--r-- | archaeological_context_records/migrations/0117_identification_m2m.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/archaeological_context_records/migrations/0117_identification_m2m.py b/archaeological_context_records/migrations/0117_identification_m2m.py new file mode 100644 index 000000000..0e91aa3e6 --- /dev/null +++ b/archaeological_context_records/migrations/0117_identification_m2m.py @@ -0,0 +1,52 @@ +# Generated by Django 2.2.24 on 2024-07-08 13:30 + +from django.db import migrations, models + + +def m2m_identification_type(apps, __): + ContextRecord = apps.get_model("archaeological_context_records", "contextrecord") + for cr in ContextRecord.objects.filter(identification__isnull=False).all(): + cr.identifications.add(cr.identification) + + +SQL1 = """ +UPDATE ishtar_common_importtarget + SET target='identifications' +WHERE target='identification'; +""" + +SQL2 = """ +UPDATE ishtar_common_formatertype + SET many_split='&' +WHERE options='archaeological_context_records.models.IdentificationType'; +""" + + +class Migration(migrations.Migration): + + dependencies = [ + ('archaeological_context_records', '0116_recordrelations_import_relationship'), + ] + + operations = [ + migrations.AlterModelOptions( + name='activitytype', + options={'ordering': ('order', 'label'), 'verbose_name': 'Activity Type', 'verbose_name_plural': 'Activity Types'}, + ), + migrations.AddField( + model_name='contextrecord', + name='identifications', + field=models.ManyToManyField(blank=True, related_name='context_records', to='archaeological_context_records.IdentificationType', verbose_name='Identification'), + ), + migrations.RunPython(m2m_identification_type), + migrations.RemoveField( + model_name='contextrecord', + name='identification', + ), + migrations.RemoveField( + model_name='historicalcontextrecord', + name='identification', + ), + migrations.RunSQL(SQL1), + migrations.RunSQL(SQL2), + ] |
