Skip to content

Commit e85b10e

Browse files
committed
Merge branch 'issue-92' of https://github.com/OskarPersson/django-pyodbc-azure into OskarPersson-issue-92
2 parents 4cc8a0d + 9ab9c89 commit e85b10e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

sql_server/pyodbc/schema.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ def _alter_field(self, model, old_field, new_field, old_type, new_type,
6767
# Drop any FK constraints, we'll remake them later
6868
fks_dropped = set()
6969
if old_field.remote_field and old_field.db_constraint:
70+
# Drop index, SQL Server requires explicit deletion
71+
if not new_field.db_constraint:
72+
index_names = self._constraint_names(model, [old_field.column], index=True)
73+
for index_name in index_names:
74+
self.execute(self._delete_constraint_sql(self.sql_delete_index, model, index_name))
75+
7076
fk_names = self._constraint_names(model, [old_field.column], foreign_key=True)
7177
if strict and len(fk_names) != 1:
7278
raise ValueError("Found wrong number (%s) of foreign key constraints for %s.%s" % (

0 commit comments

Comments
 (0)