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 6548ef3
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 9 deletions.
5 changes: 4 additions & 1 deletion enterprise_subsidy/apps/api/v1/views/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,10 @@ def base_queryset(self):
for learner_only_context in learner_only_contexts:
# For each context (enterprise_customer_uuid) that the requester only has learner access to, filter
# transactions related to that context to only include their own transactions.
# pylint: disable=unsupported-binary-operation
# AED 2023-10-31: locally, pylint complains of the binary operation.
# In github actions, pylint complains of a useless-suppression.
# Suppressing both and letting the code gods sort it out.
# pylint: disable=unsupported-binary-operation,useless-suppression
if request_jwt.get('user_id'):
queryset = queryset.filter(
(
Expand Down
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',
),
]
8 changes: 0 additions & 8 deletions enterprise_subsidy/apps/subsidy/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from uuid import uuid4

from django.db import models
from django.db.models import Q
from django.utils.functional import cached_property
from edx_rbac.models import UserRole, UserRoleAssignment
from edx_rbac.utils import ALL_ACCESS_CONTEXT
Expand Down Expand Up @@ -104,13 +103,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 6548ef3

Please sign in to comment.