From fba0eaa5d60603721d7b4653e3efacbfb3613bd2 Mon Sep 17 00:00:00 2001 From: Josh Schneier Date: Sun, 11 Jun 2017 20:05:54 -0400 Subject: Fixed #28298 -- Prevented a primary key alteration from adding a foreign key constraint if db_constraint=False. --- django/db/backends/base/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'django') diff --git a/django/db/backends/base/schema.py b/django/db/backends/base/schema.py index 91ee3dac22..c24e809570 100644 --- a/django/db/backends/base/schema.py +++ b/django/db/backends/base/schema.py @@ -727,7 +727,7 @@ class BaseDatabaseSchemaEditor: # Rebuild FKs that pointed to us if we previously had to drop them if old_field.primary_key and new_field.primary_key and old_type != new_type: for rel in new_field.model._meta.related_objects: - if not rel.many_to_many: + if not rel.many_to_many and rel.field.db_constraint: self.execute(self._create_fk_sql(rel.related_model, rel.field, "_fk")) # Does it have check constraints we need to add? if old_db_params['check'] != new_db_params['check'] and new_db_params['check']: -- cgit v1.3