Skip to content

Commit

Permalink
add is_migrated field
Browse files Browse the repository at this point in the history
  • Loading branch information
sainak committed May 20, 2024
1 parent d39567b commit 3e0b86e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions care/facility/api/serializers/consultation_symptom.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Meta:
read_only_fields = (
"created_date",
"modified_date",
"is_migrated",
)

def validate(self, attrs):
Expand Down
9 changes: 9 additions & 0 deletions care/facility/migrations/0437_symptoms_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def backfill_symptoms_table(apps, schema_editor):
created_date=consultation.created_date,
created_by=consultation.created_by,
consultation=consultation,
is_migrated=True,
)
)
except ValueError:
Expand All @@ -57,6 +58,7 @@ def backfill_symptoms_table(apps, schema_editor):
created_date=daily_round.created_date,
created_by=daily_round.created_by,
consultation=daily_round.consultation,
is_migrated=True,
)
)
except ValueError:
Expand Down Expand Up @@ -193,6 +195,13 @@ class Migration(migrations.Migration):
to=settings.AUTH_USER_MODEL,
),
),
(
"is_migrated",
models.BooleanField(
default=False,
help_text="This field is to throw caution to data that was previously ported over",
),
),
],
options={
"abstract": False,
Expand Down
4 changes: 4 additions & 0 deletions care/facility/models/consultation_symptom.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ class ConsultationSymptom(BaseModel, ConsultationRelatedPermissionMixin):
updated_by = models.ForeignKey(
"users.User", null=True, blank=True, on_delete=models.PROTECT, related_name="+"
)
is_migrated = models.BooleanField(
default=False,
help_text="This field is to throw caution to data that was previously ported over",
)

def save(self, *args, **kwargs):
if self.other_symptom and self.symptom != Symptom.OTHERS:
Expand Down

0 comments on commit 3e0b86e

Please sign in to comment.