Skip to content

Commit

Permalink
fix: remove unapplicable conditional unique constraint on subsidy
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
iloveagent57 committed Oct 31, 2023
1 parent 190a779 commit ecfd36d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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'},
),
]
Original file line number Diff line number Diff line change
@@ -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',
),
]
7 changes: 0 additions & 7 deletions enterprise_subsidy/apps/subsidy/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ecfd36d

Please sign in to comment.