From ecfd36d5bef034f2e1a0f4816e8ac0468c274e19 Mon Sep 17 00:00:00 2001 From: Alex Dusenbery Date: Tue, 31 Oct 2023 09:07:04 -0400 Subject: [PATCH] fix: remove unapplicable conditional unique constraint on subsidy ENT-7891 | MySQL has never supported conditional unique constraints. This commit removes a conditional unique constraint declared in the subsidy model's Meta class. It also has a no-op migration for same. Lastly, adds a migration for historical subsidy records from upgraded django-simple-history. --- .../0019_alter_historicalsubsidy_options.py | 17 +++++++++++++++++ ..._subsidy_unique_reference_id_non_internal.py | 17 +++++++++++++++++ enterprise_subsidy/apps/subsidy/models.py | 7 ------- 3 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 enterprise_subsidy/apps/subsidy/migrations/0019_alter_historicalsubsidy_options.py create mode 100644 enterprise_subsidy/apps/subsidy/migrations/0020_remove_subsidy_unique_reference_id_non_internal.py diff --git a/enterprise_subsidy/apps/subsidy/migrations/0019_alter_historicalsubsidy_options.py b/enterprise_subsidy/apps/subsidy/migrations/0019_alter_historicalsubsidy_options.py new file mode 100644 index 00000000..fb48272b --- /dev/null +++ b/enterprise_subsidy/apps/subsidy/migrations/0019_alter_historicalsubsidy_options.py @@ -0,0 +1,17 @@ +# Generated by Django 3.2.19 on 2023-10-31 13:02 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('subsidy', '0018_alter_historicalsubsidy_options'), + ] + + operations = [ + migrations.AlterModelOptions( + name='historicalsubsidy', + options={'get_latest_by': 'history_date', 'ordering': ('-history_date', '-history_id'), 'verbose_name': 'historical subsidy'}, + ), + ] diff --git a/enterprise_subsidy/apps/subsidy/migrations/0020_remove_subsidy_unique_reference_id_non_internal.py b/enterprise_subsidy/apps/subsidy/migrations/0020_remove_subsidy_unique_reference_id_non_internal.py new file mode 100644 index 00000000..fe4d43c0 --- /dev/null +++ b/enterprise_subsidy/apps/subsidy/migrations/0020_remove_subsidy_unique_reference_id_non_internal.py @@ -0,0 +1,17 @@ +# Generated by Django 3.2.19 on 2023-10-31 13:04 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('subsidy', '0019_alter_historicalsubsidy_options'), + ] + + operations = [ + migrations.RemoveConstraint( + model_name='subsidy', + name='unique_reference_id_non_internal', + ), + ] diff --git a/enterprise_subsidy/apps/subsidy/models.py b/enterprise_subsidy/apps/subsidy/models.py index 211c5c44..1bf267e6 100644 --- a/enterprise_subsidy/apps/subsidy/models.py +++ b/enterprise_subsidy/apps/subsidy/models.py @@ -104,13 +104,6 @@ class Meta: """ Metaclass for Subsidy. """ - constraints = [ - models.UniqueConstraint( - condition=Q(internal_only=False), # Allow more flexibility for internal/test subsidies. - fields=["reference_id", "reference_type"], - name="unique_reference_id_non_internal", - ) - ] ordering = ['-created'] # Please reserve the "subsidy_type" field name for the future when we use it to distinguish between