summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2017-03-31 18:42:08 -0400
committerSimon Charette <charette.s@gmail.com>2017-04-02 16:34:03 -0400
commit35c0025151ad411e691a2fa62a0dd3507ebafd82 (patch)
tree1ec91eb505860f0f2fc855c2def50146fb2b7875 /django
parent5e710cf4a5dba1fc30e3b6775b83c2218e57cd36 (diff)
Fixed #27928 -- Avoided SET/DROP DEFAULT unless a field changes from null to non-null.
Thanks Christophe Pettus, Matteo Pietro Russo for reports and Tim for review.
Diffstat (limited to 'django')
-rw-r--r--django/db/backends/base/schema.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/django/db/backends/base/schema.py b/django/db/backends/base/schema.py
index 49a29e5b37..ed3fb07d86 100644
--- a/django/db/backends/base/schema.py
+++ b/django/db/backends/base/schema.py
@@ -578,6 +578,8 @@ class BaseDatabaseSchemaEditor:
old_default = self.effective_default(old_field)
new_default = self.effective_default(new_field)
needs_database_default = (
+ old_field.null and
+ not new_field.null and
old_default != new_default and
new_default is not None and
not self.skip_default(new_field)