Merge pull request #14481 from edx/ahsan/ECOM-7085-Create-migration-unique-email
Added unique constraint on email
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('student', '0009_auto_20170111_0422'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunSQL(
|
||||
"create unique index email on auth_user (email);",
|
||||
"drop index email on auth_user;"
|
||||
)
|
||||
]
|
||||
@@ -45,13 +45,15 @@ class StudentModuleHistoryExtendedRouter(object):
|
||||
return False
|
||||
return None
|
||||
|
||||
def allow_migrate(self, db, model): # pylint: disable=unused-argument
|
||||
def allow_migrate(self, db, app_label, model_name=None, **hints): # pylint: disable=unused-argument
|
||||
"""
|
||||
Only sync StudentModuleHistoryExtended to StudentModuleHistoryExtendedRouter.DATABASE_Name
|
||||
"""
|
||||
if self._is_csmh(model):
|
||||
return db == self.DATABASE_NAME
|
||||
elif db == self.DATABASE_NAME:
|
||||
if model_name is not None:
|
||||
model = hints.get('model')
|
||||
if self._is_csmh(model):
|
||||
return db == self.DATABASE_NAME
|
||||
if db == self.DATABASE_NAME:
|
||||
return False
|
||||
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user