Skip to content

Commit fc3aea0

Browse files
committed
Merge branch 'azure-1.11' into azure-2.0
2 parents 549026d + 1768047 commit fc3aea0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sql_server/pyodbc/schema.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,9 @@ def _alter_field(self, model, old_field, new_field, old_type, new_type,
317317
for sql, params in post_actions:
318318
self.execute(sql, params)
319319
# Added a unique?
320-
if not old_field.unique and new_field.unique:
320+
if (not old_field.unique and new_field.unique) or (
321+
old_field.primary_key and not new_field.primary_key and new_field.unique
322+
):
321323
self.execute(self._create_unique_sql(model, [new_field.column]))
322324
# Added an index?
323325
# constraint will no longer be used in lieu of an index. The following

0 commit comments

Comments
 (0)