summaryrefslogtreecommitdiff
path: root/archaeological_context_records/migrations
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2024-07-08 14:09:48 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2024-07-08 18:15:40 +0200
commitf2133b1363d3d275ce063c0cddebb3fb862e2637 (patch)
tree0131f651e3a8bb5347eda18622daf75523f92c82 /archaeological_context_records/migrations
parent4869a23a5adeeba3160267537ce6acccdf1a3aae (diff)
downloadIshtar-f2133b1363d3d275ce063c0cddebb3fb862e2637.tar.bz2
Ishtar-f2133b1363d3d275ce063c0cddebb3fb862e2637.zip
✨ Context records - identification: switch to multivalued
Diffstat (limited to 'archaeological_context_records/migrations')
-rw-r--r--archaeological_context_records/migrations/0117_identification_m2m.py52
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),
+ ]