Skip to content

Commit

Permalink
fix: add unique constraint to test flag bridge (#414)
Browse files Browse the repository at this point in the history
* fix: add unique constraint to test flag bridge

* fix: tests
  • Loading branch information
joseph-sentry authored Nov 6, 2024
1 parent bf285c7 commit 6958f32
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 4.2.16 on 2024-11-05 20:47

from django.db import migrations, models

"""
BEGIN;
--
-- Create constraint reports_test_results_flag_bridge_flag_test on model testflagbridge
--
ALTER TABLE "reports_test_results_flag_bridge" ADD CONSTRAINT "reports_test_results_flag_bridge_flag_test" UNIQUE ("flag_id", "test_id");
COMMIT;
"""


class Migration(migrations.Migration):
dependencies = [
("reports", "0029_alter_dailytestrollup_branch"),
]

operations = [
migrations.AddConstraint(
model_name="testflagbridge",
constraint=models.UniqueConstraint(
fields=("flag", "test"),
name="reports_test_results_flag_bridge_flag_test",
),
),
]
6 changes: 6 additions & 0 deletions shared/django_apps/reports/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,3 +466,9 @@ class TestFlagBridge(models.Model):
class Meta:
app_label = REPORTS_APP_LABEL
db_table = "reports_test_results_flag_bridge"
constraints = [
models.UniqueConstraint(
fields=["flag", "test"],
name="reports_test_results_flag_bridge_flag_test",
)
]

0 comments on commit 6958f32

Please sign in to comment.