Skip to content

Commit

Permalink
Merge branch 'azure-1.11' into azure-2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
michiya committed Jan 28, 2018
2 parents 86ffab9 + e85b10e commit 72235c1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sql_server/pyodbc/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ def _alter_field(self, model, old_field, new_field, old_type, new_type,
# Drop any FK constraints, we'll remake them later
fks_dropped = set()
if old_field.remote_field and old_field.db_constraint:
# Drop index, SQL Server requires explicit deletion
if not new_field.db_constraint:
index_names = self._constraint_names(model, [old_field.column], index=True)
for index_name in index_names:
self.execute(self._delete_constraint_sql(self.sql_delete_index, model, index_name))

fk_names = self._constraint_names(model, [old_field.column], foreign_key=True)
if strict and len(fk_names) != 1:
raise ValueError("Found wrong number (%s) of foreign key constraints for %s.%s" % (
Expand Down

0 comments on commit 72235c1

Please sign in to comment.