Skip to content

Commit f45970f

Browse files
committed
Prevent AttributeError when AlterField removes a constraint
1 parent 10da334 commit f45970f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sql_server/pyodbc/schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def _alter_field(self, model, old_field, new_field, old_type, new_type,
6868
fks_dropped = set()
6969
if old_field.remote_field and old_field.db_constraint:
7070
# Drop index, SQL Server requires explicit deletion
71-
if not new_field.db_constraint:
71+
if not hasattr(new_field, 'db_constraint') or not new_field.db_constraint:
7272
index_names = self._constraint_names(model, [old_field.column], index=True)
7373
for index_name in index_names:
7474
self.execute(self._delete_constraint_sql(self.sql_delete_index, model, index_name))

0 commit comments

Comments
 (0)