From d25c3d0e4bef1126d6bb37cb07e9dff100ea393e Mon Sep 17 00:00:00 2001 From: John Nagro Date: Thu, 18 Jan 2024 20:29:20 +0000 Subject: [PATCH] fix: attempting to frame up a solution --- .../migrations/0018_auto_20240110_1301.py | 4 +- .../migrations/0019_auto_20240118_1822.py | 45 ++++++++----------- .../integrated_channel/models.py | 2 + 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/integrated_channels/blackboard/migrations/0018_auto_20240110_1301.py b/integrated_channels/blackboard/migrations/0018_auto_20240110_1301.py index 8065735497..24fbbe5f7c 100644 --- a/integrated_channels/blackboard/migrations/0018_auto_20240110_1301.py +++ b/integrated_channels/blackboard/migrations/0018_auto_20240110_1301.py @@ -24,4 +24,6 @@ class Migration(migrations.Migration): # ), # ] - operations = [] + operations = [ + migrations.RunPython(migrations.RunPython.noop, reverse_code=migrations.RunPython.noop) + ] diff --git a/integrated_channels/blackboard/migrations/0019_auto_20240118_1822.py b/integrated_channels/blackboard/migrations/0019_auto_20240118_1822.py index 21c352992e..03d8e73f19 100644 --- a/integrated_channels/blackboard/migrations/0019_auto_20240118_1822.py +++ b/integrated_channels/blackboard/migrations/0019_auto_20240118_1822.py @@ -1,8 +1,22 @@ # Generated by Django 3.2.22 on 2024-01-18 18:22 -from django.apps import apps from django.db import migrations from django.core.exceptions import FieldDoesNotExist +from integrated_channels.blackboard.models import * + + +def forwards_func(apps, schema_editor): + try: + if field := BlackboardLearnerDataTransmissionAudit._meta.get_field('transmission_status'): + schema_editor.remove_field(BlackboardLearnerDataTransmissionAudit, field) + except FieldDoesNotExist: + pass + + try: + if field := BlackboardLearnerAssessmentDataTransmissionAudit._meta.get_field('transmission_status'): + schema_editor.remove_field(BlackboardLearnerAssessmentDataTransmissionAudit, field) + except FieldDoesNotExist: + pass class Migration(migrations.Migration): @@ -16,29 +30,6 @@ class Migration(migrations.Migration): # this migration conditionally cleans up the previous migration operations # only if they were part of the partially applied ones - BlackboardLearnerAssessmentDataTransmissionAudit = apps.get_model('blackboard', 'BlackboardLearnerAssessmentDataTransmissionAudit') - BlackboardLearnerDataTransmissionAudit = apps.get_model('blackboard', 'BlackboardLearnerDataTransmissionAudit') - - operations = [] - - try: - if BlackboardLearnerDataTransmissionAudit._meta.get_field('transmission_status'): - operations.append( - migrations.RemoveField( - model_name='blackboardlearnerdatatransmissionaudit', - name='transmission_status', - ) - ) - except FieldDoesNotExist: - pass - - try: - if BlackboardLearnerAssessmentDataTransmissionAudit._meta.get_field('transmission_status'): - operations.append( - migrations.RemoveField( - model_name='blackboardlearnerassessmentdatatransmissionaudit', - name='transmission_status', - ) - ) - except FieldDoesNotExist: - pass + operations = [ + migrations.RunPython(forwards_func, reverse_code=migrations.RunPython.noop) + ] diff --git a/integrated_channels/integrated_channel/models.py b/integrated_channels/integrated_channel/models.py index eecfa7c1f8..e3e585246e 100644 --- a/integrated_channels/integrated_channel/models.py +++ b/integrated_channels/integrated_channel/models.py @@ -533,6 +533,8 @@ class LearnerDataTransmissionAudit(TimeStampedModel): help_text=_('Data pertaining to the transmissions API request response.') ) + transmission_status = models.JSONField(default=list, blank=True, null=True) + class Meta: abstract = True app_label = 'integrated_channel'