diff options
| author | Andrew Godwin <andrew@aeracode.org> | 2014-08-04 11:58:44 +1000 |
|---|---|---|
| committer | Andrew Godwin <andrew@aeracode.org> | 2014-08-04 11:59:29 +1000 |
| commit | c06e124b5e73bd99c6ec563c64fd50d6a45457d8 (patch) | |
| tree | 1817236008a0e137713f6e3d9d2f1b3137e14697 /django | |
| parent | 1b00738f73444693dd94958f3fc53c089f4d96e7 (diff) | |
Fixed #23091: CreateModel and AddField were clashing with deferred SQL
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/backends/schema.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/django/db/backends/schema.py b/django/db/backends/schema.py index c9052e29d8..b10412751d 100644 --- a/django/db/backends/schema.py +++ b/django/db/backends/schema.py @@ -546,6 +546,7 @@ class BaseDatabaseSchemaEditor(object): } ) # Drop any FK constraints, we'll remake them later + fks_dropped = set() if old_field.rel: fk_names = self._constraint_names(model, [old_field.column], foreign_key=True) if strict and len(fk_names) != 1: @@ -555,6 +556,7 @@ class BaseDatabaseSchemaEditor(object): old_field.column, )) for fk_name in fk_names: + fks_dropped.add((old_field.column,)) self.execute( self.sql_delete_fk % { "table": self.quote_name(model._meta.db_table), @@ -737,7 +739,7 @@ class BaseDatabaseSchemaEditor(object): } ) # Does it have a foreign key? - if new_field.rel: + if new_field.rel and fks_dropped: to_table = new_field.rel.to._meta.db_table to_column = new_field.rel.get_related_field().column self.execute( |
