Add unique constraint to ProgramEnrollment model
This commit is contained in:
committed by
Alex Dusenbery
parent
ff07b3057e
commit
bf661eaa8d
@@ -0,0 +1,21 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.20 on 2019-04-24 16:22
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('program_enrollments', '0002_historicalprogramcourseenrollment_programcourseenrollment'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterUniqueTogether(
|
||||
name='programenrollment',
|
||||
unique_together=set([('user', 'external_user_key', 'program_uuid', 'curriculum_uuid')]),
|
||||
),
|
||||
]
|
||||
@@ -30,6 +30,12 @@ class ProgramEnrollment(TimeStampedModel): # pylint: disable=model-missing-unic
|
||||
class Meta(object):
|
||||
app_label = "program_enrollments"
|
||||
|
||||
# A student enrolled in a given (program, curriculum) should always
|
||||
# have a non-null ``user`` or ``external_user_key`` field (or both).
|
||||
unique_together = (
|
||||
('user', 'external_user_key', 'program_uuid', 'curriculum_uuid'),
|
||||
)
|
||||
|
||||
user = models.ForeignKey(
|
||||
User,
|
||||
null=True,
|
||||
|
||||
Reference in New Issue
Block a user