Skip to content

Commit 72235c1

Browse files
committed
Merge branch 'azure-1.11' into azure-2.0
2 parents 86ffab9 + e85b10e commit 72235c1

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
@@ -134,6 +134,12 @@ def _alter_field(self, model, old_field, new_field, old_type, new_type,
134134
# Drop any FK constraints, we'll remake them later
135135
fks_dropped = set()
136136
if old_field.remote_field and old_field.db_constraint:
137+
# Drop index, SQL Server requires explicit deletion
138+
if not new_field.db_constraint:
139+
index_names = self._constraint_names(model, [old_field.column], index=True)
140+
for index_name in index_names:
141+
self.execute(self._delete_constraint_sql(self.sql_delete_index, model, index_name))
142+
137143
fk_names = self._constraint_names(model, [old_field.column], foreign_key=True)
138144
if strict and len(fk_names) != 1:
139145
raise ValueError("Found wrong number (%s) of foreign key constraints for %s.%s" % (

0 commit comments

Comments
 (0)