From dfe91d938cd6d5553b4c6e9b92075c58c1d384db Mon Sep 17 00:00:00 2001 From: Varsha Menon Date: Wed, 24 Jul 2024 10:58:45 -0400 Subject: [PATCH] feat: add unique constraint to coursestaffrole --- ..._coursestaffrole_unique_course_staff_role.py | 17 +++++++++++++++++ edx_exams/apps/core/models.py | 5 +++++ 2 files changed, 22 insertions(+) create mode 100644 edx_exams/apps/core/migrations/0027_coursestaffrole_unique_course_staff_role.py diff --git a/edx_exams/apps/core/migrations/0027_coursestaffrole_unique_course_staff_role.py b/edx_exams/apps/core/migrations/0027_coursestaffrole_unique_course_staff_role.py new file mode 100644 index 00000000..395ec327 --- /dev/null +++ b/edx_exams/apps/core/migrations/0027_coursestaffrole_unique_course_staff_role.py @@ -0,0 +1,17 @@ +# Generated by Django 4.2.14 on 2024-07-24 14:58 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0026_studentallowance'), + ] + + operations = [ + migrations.AddConstraint( + model_name='coursestaffrole', + constraint=models.UniqueConstraint(fields=('user', 'course_id', 'role'), name='unique_course_staff_role'), + ), + ] diff --git a/edx_exams/apps/core/models.py b/edx_exams/apps/core/models.py index 52456fc5..dd8d805d 100644 --- a/edx_exams/apps/core/models.py +++ b/edx_exams/apps/core/models.py @@ -73,6 +73,11 @@ class Meta: db_table = 'exams_coursestaffrole' verbose_name = 'course staff role' + constraints = [ + models.UniqueConstraint(fields=['user', 'course_id', 'role'], + name='unique_course_staff_role') + ] + class ProctoringProvider(TimeStampedModel): """