From 862f1033d51b5a40aee273c8dbb5105432bdb3d9 Mon Sep 17 00:00:00 2001
From: root <root@prc-test.parkinson.lu>
Date: Tue, 12 Jan 2021 10:38:33 +0100
Subject: [PATCH] migration script was failing when db v0.15.x contained
 subjects

---
 CHANGELOG                                     |  6 +++
 .../0190_remove_study_related_fields.py       | 50 +++++++++----------
 2 files changed, 31 insertions(+), 25 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index bcb023d6..1953dd3d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,9 @@
+smasch (1.0.0~beta.3-1) unstable; urgency=low
+
+  * bug fix: upgrade from 0.15 version containing subjects failed
+
+ -- Piotr Gawron <piotr.gawron@uni.lu>  Tue, 12 Jan 2021 10:00:00 +0200
+
 smasch (1.0.0~beta.2-1) unstable; urgency=low
 
   * bug fix: npm dependencies must be more strict
diff --git a/smash/web/migrations/0190_remove_study_related_fields.py b/smash/web/migrations/0190_remove_study_related_fields.py
index c95ddbfc..6b7207d1 100644
--- a/smash/web/migrations/0190_remove_study_related_fields.py
+++ b/smash/web/migrations/0190_remove_study_related_fields.py
@@ -38,156 +38,156 @@ def create_custom_fields(apps, schema_editor):
                                                                            type=CUSTOM_FIELD_TYPE_SELECT_LIST,
                                                                            study_id=GLOBAL_STUDY_ID,
                                                                            possible_values="N/A;Positive;Negative;Inconclusive",
-                                                                           default="N/A",
+                                                                           default_value="N/A",
                                                                            readonly=True)
         virus_test_2_result_field = CustomStudySubjectField.objects.create(name="Virus 1 RT-PCR",
                                                                            type=CUSTOM_FIELD_TYPE_SELECT_LIST,
                                                                            study_id=GLOBAL_STUDY_ID,
                                                                            possible_values="N/A;Positive;Negative;Inconclusive",
-                                                                           default="N/A",
+                                                                           default_value="N/A",
                                                                            readonly=True)
         virus_test_3_result_field = CustomStudySubjectField.objects.create(name="Virus 2 RT-PCR",
                                                                            type=CUSTOM_FIELD_TYPE_SELECT_LIST,
                                                                            study_id=GLOBAL_STUDY_ID,
                                                                            possible_values="N/A;Positive;Negative;Inconclusive",
-                                                                           default="N/A",
+                                                                           default_value="N/A",
                                                                            readonly=True)
         virus_test_4_result_field = CustomStudySubjectField.objects.create(name="Virus 3 RT-PCR",
                                                                            type=CUSTOM_FIELD_TYPE_SELECT_LIST,
                                                                            study_id=GLOBAL_STUDY_ID,
                                                                            possible_values="N/A;Positive;Negative;Inconclusive",
-                                                                           default="N/A",
+                                                                           default_value="N/A",
                                                                            readonly=True)
         virus_test_5_result_field = CustomStudySubjectField.objects.create(name="Virus 4 RT-PCR",
                                                                            type=CUSTOM_FIELD_TYPE_SELECT_LIST,
                                                                            study_id=GLOBAL_STUDY_ID,
                                                                            possible_values="N/A;Positive;Negative;Inconclusive",
-                                                                           default="N/A",
+                                                                           default_value="N/A",
                                                                            readonly=True)
         virus_test_1_updated_field = CustomStudySubjectField.objects.create(name="Visit 0 RT-PCR update date",
                                                                             type=CUSTOM_FIELD_TYPE_DATE,
                                                                             study_id=GLOBAL_STUDY_ID,
-                                                                            default="",
+                                                                            default_value="",
                                                                             readonly=True)
         virus_test_2_updated_field = CustomStudySubjectField.objects.create(name="Visit 1 RT-PCR update date",
                                                                             type=CUSTOM_FIELD_TYPE_DATE,
                                                                             study_id=GLOBAL_STUDY_ID,
-                                                                            default="",
+                                                                            default_value="",
                                                                             readonly=True)
         virus_test_3_updated_field = CustomStudySubjectField.objects.create(name="Visit 2 RT-PCR update date",
                                                                             type=CUSTOM_FIELD_TYPE_DATE,
                                                                             study_id=GLOBAL_STUDY_ID,
-                                                                            default="",
+                                                                            default_value="",
                                                                             readonly=True)
         virus_test_4_updated_field = CustomStudySubjectField.objects.create(name="Visit 3 RT-PCR update date",
                                                                             type=CUSTOM_FIELD_TYPE_DATE,
                                                                             study_id=GLOBAL_STUDY_ID,
-                                                                            default="",
+                                                                            default_value="",
                                                                             readonly=True)
         virus_test_5_updated_field = CustomStudySubjectField.objects.create(name="Visit 4 RT-PCR update date",
                                                                             type=CUSTOM_FIELD_TYPE_DATE,
                                                                             study_id=GLOBAL_STUDY_ID,
-                                                                            default="",
+                                                                            default_value="",
                                                                             readonly=True)
         virus_test_1_collection_date_field = CustomStudySubjectField.objects.create(
             name="Visit 0 RT-PCR collection date",
             type=CUSTOM_FIELD_TYPE_DATE,
             study_id=GLOBAL_STUDY_ID,
-            default="",
+            default_value="",
             readonly=True)
         virus_test_2_collection_date_field = CustomStudySubjectField.objects.create(
             name="Visit 1 RT-PCR collection date",
             type=CUSTOM_FIELD_TYPE_DATE,
             study_id=GLOBAL_STUDY_ID,
-            default="",
+            default_value="",
             readonly=True)
         virus_test_3_collection_date_field = CustomStudySubjectField.objects.create(
             name="Visit 2 RT-PCR collection date",
             type=CUSTOM_FIELD_TYPE_DATE,
             study_id=GLOBAL_STUDY_ID,
-            default="",
+            default_value="",
             readonly=True)
         virus_test_4_collection_date_field = CustomStudySubjectField.objects.create(
             name="Visit 3 RT-PCR collection date",
             type=CUSTOM_FIELD_TYPE_DATE,
             study_id=GLOBAL_STUDY_ID,
-            default="",
+            default_value="",
             readonly=True)
         virus_test_5_collection_date_field = CustomStudySubjectField.objects.create(
             name="Visit 4 RT-PCR collection date",
             type=CUSTOM_FIELD_TYPE_DATE,
             study_id=GLOBAL_STUDY_ID,
-            default="",
+            default_value="",
             readonly=True)
         virus_test_1_iga_status_field = CustomStudySubjectField.objects.create(
             name="Visit 0 IgA Status",
             type=CUSTOM_FIELD_TYPE_SELECT_LIST,
             study_id=GLOBAL_STUDY_ID,
             possible_values="N/A;Positive;Negative;Borderline",
-            default="N/A",
+            default_value="N/A",
             readonly=True)
         virus_test_2_iga_status_field = CustomStudySubjectField.objects.create(
             name="Visit 1 IgA Status",
             type=CUSTOM_FIELD_TYPE_SELECT_LIST,
             study_id=GLOBAL_STUDY_ID,
             possible_values="N/A;Positive;Negative;Borderline",
-            default="N/A",
+            default_value="N/A",
             readonly=True)
         virus_test_3_iga_status_field = CustomStudySubjectField.objects.create(
             name="Visit 2 IgA Status",
             type=CUSTOM_FIELD_TYPE_SELECT_LIST,
             study_id=GLOBAL_STUDY_ID,
             possible_values="N/A;Positive;Negative;Borderline",
-            default="N/A",
+            default_value="N/A",
             readonly=True)
         virus_test_4_iga_status_field = CustomStudySubjectField.objects.create(
             name="Visit 3 IgA Status",
             type=CUSTOM_FIELD_TYPE_SELECT_LIST,
             study_id=GLOBAL_STUDY_ID,
             possible_values="N/A;Positive;Negative;Borderline",
-            default="N/A",
+            default_value="N/A",
             readonly=True)
         virus_test_5_iga_status_field = CustomStudySubjectField.objects.create(
             name="Visit 4 IgA Status",
             type=CUSTOM_FIELD_TYPE_SELECT_LIST,
             study_id=GLOBAL_STUDY_ID,
             possible_values="N/A;Positive;Negative;Borderline",
-            default="N/A",
+            default_value="N/A",
             readonly=True)
         virus_test_1_igg_status_field = CustomStudySubjectField.objects.create(
             name="Visit 0 IgG Status",
             type=CUSTOM_FIELD_TYPE_SELECT_LIST,
             study_id=GLOBAL_STUDY_ID,
             possible_values="N/A;Positive;Negative;Borderline",
-            default="N/A",
+            default_value="N/A",
             readonly=True)
         virus_test_2_igg_status_field = CustomStudySubjectField.objects.create(
             name="Visit 1 IgG Status",
             type=CUSTOM_FIELD_TYPE_SELECT_LIST,
             study_id=GLOBAL_STUDY_ID,
             possible_values="N/A;Positive;Negative;Borderline",
-            default="N/A",
+            default_value="N/A",
             readonly=True)
         virus_test_3_igg_status_field = CustomStudySubjectField.objects.create(
             name="Visit 2 IgG Status",
             type=CUSTOM_FIELD_TYPE_SELECT_LIST,
             study_id=GLOBAL_STUDY_ID,
             possible_values="N/A;Positive;Negative;Borderline",
-            default="N/A",
+            default_value="N/A",
             readonly=True)
         virus_test_4_igg_status_field = CustomStudySubjectField.objects.create(
             name="Visit 3 IgG Status",
             type=CUSTOM_FIELD_TYPE_SELECT_LIST,
             study_id=GLOBAL_STUDY_ID,
             possible_values="N/A;Positive;Negative;Borderline",
-            default="N/A",
+            default_value="N/A",
             readonly=True)
         virus_test_5_igg_status_field = CustomStudySubjectField.objects.create(
             name="Visit 4 IgG Status",
             type=CUSTOM_FIELD_TYPE_SELECT_LIST,
             study_id=GLOBAL_STUDY_ID,
             possible_values="N/A;Positive;Negative;Borderline",
-            default="N/A",
+            default_value="N/A",
             readonly=True)
 
         for subject in StudySubject.objects.all():
-- 
GitLab