aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/api/migrations
diff options
context:
space:
mode:
authorGravatar Leon Sandøy <[email protected]>2020-07-29 19:07:03 +0200
committerGravatar Leon Sandøy <[email protected]>2020-07-29 19:07:03 +0200
commit12f447bc9636382a623e6b30ae43ccc036c488b5 (patch)
tree9e96bf98d684dcb91c359e66b882fdeee6bef4d6 /pydis_site/apps/api/migrations
parentFix multiple leafs for migration graph. (diff)
Add a constraint in the DB model as well.
This really should've been handled automatically by DRF, and in the future, it will be. But for now, we need to have constraints both on the serializer (to get status code 400), and on the model (to prevent direct database constraint violations). See https://github.com/encode/django-rest-framework/issues/7173
Diffstat (limited to 'pydis_site/apps/api/migrations')
-rw-r--r--pydis_site/apps/api/migrations/0058_create_new_filterlist_model.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/pydis_site/apps/api/migrations/0058_create_new_filterlist_model.py b/pydis_site/apps/api/migrations/0058_create_new_filterlist_model.py
index fffb8159..aecfdad7 100644
--- a/pydis_site/apps/api/migrations/0058_create_new_filterlist_model.py
+++ b/pydis_site/apps/api/migrations/0058_create_new_filterlist_model.py
@@ -25,5 +25,9 @@ class Migration(migrations.Migration):
('comment', models.TextField(help_text="Optional comment on this entry.", null=True)),
],
bases=(pydis_site.apps.api.models.mixins.ModelReprMixin, models.Model),
+ ),
+ migrations.AddConstraint(
+ model_name='filterlist',
+ constraint=models.UniqueConstraint(fields=('content', 'type'), name='unique_filter_list')
)
]