Skip to content

Commit

Permalink
remove types from migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
shivankacker committed Jun 6, 2024
1 parent f243b65 commit 137cfb8
Showing 1 changed file with 5 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,13 @@
from django.utils import timezone

import care.facility.models.mixins.permissions.patient
from care.facility.models.file_upload import FileUpload as FileUploadModel
from care.facility.models.patient_consultation import (
PatientConsent as PatientConsentModel,
)
from care.facility.models.patient_consultation import (
PatientConsultation as PatientConsultationModel,
)


class Migration(migrations.Migration):
def migrate_consents(apps, schema_editor):
PatientConsultation: PatientConsultationModel = apps.get_model(
"facility", "PatientConsultation"
)
PatientConsent: PatientConsentModel = apps.get_model(
"facility", "PatientConsent"
)
FileUpload: FileUploadModel = apps.get_model("facility", "FileUpload")
PatientConsultation = apps.get_model("facility", "PatientConsultation")
PatientConsent = apps.get_model("facility", "PatientConsent")
FileUpload = apps.get_model("facility", "FileUpload")
consultations = PatientConsultation.objects.filter(
consent_records__isnull=False
)
Expand All @@ -44,7 +33,7 @@ def migrate_consents(apps, schema_editor):

files = FileUpload.objects.filter(
associating_id=old_id,
file_type=FileUploadModel.FileType.CONSENT_RECORD,
file_type=7,
)

kwargs = {
Expand All @@ -63,9 +52,7 @@ def migrate_consents(apps, schema_editor):
files.update(**kwargs)

def reverse_migrate(apps, schema_editor):
PatientConsent: PatientConsentModel = apps.get_model(
"facility", "PatientConsent"
)
PatientConsent = apps.get_model("facility", "PatientConsent")
for consent in PatientConsent.objects.all():
consultation = consent.consultation
consultation.consent_records.append(
Expand Down

0 comments on commit 137cfb8

Please sign in to comment.