summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorCaio Ariede <caio.ariede@gmail.com>2019-10-04 10:55:41 -0300
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-10-07 14:37:39 +0200
commit46a05e10a420deae3158c502ce58cf25ab59ccb1 (patch)
tree1722c423b692b2cd6dc2b7cb87129ef1c885de33 /docs
parent98573cfe48b6c52dd0655f649e4180df3c6cc635 (diff)
[2.2.x] Fixed #28273 -- Doc'd fast nullable column creation with defaults.
Backport of 06909fe084f87a65459a83bd69d7cdbe4fce9a7c from master
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/migration-operations.txt15
1 files changed, 15 insertions, 0 deletions
diff --git a/docs/ref/migration-operations.txt b/docs/ref/migration-operations.txt
index f7778c2979..804a6cbe52 100644
--- a/docs/ref/migration-operations.txt
+++ b/docs/ref/migration-operations.txt
@@ -150,6 +150,21 @@ a default value to put into existing rows. It does not affect the behavior
of setting defaults in the database directly - Django never sets database
defaults and always applies them in the Django ORM code.
+.. warning::
+
+ On older databases, adding a field with a default value may cause a full
+ rewrite of the table. This happens even for nullable fields and may have a
+ negative performance impact. To avoid that, the following steps should be
+ taken.
+
+ * Add the nullable field without the default value and run the
+ :djadmin:`makemigrations` command. This should generate a migration with
+ an ``AddField`` operation.
+
+ * Add the default value to your field and run the :djadmin:`makemigrations`
+ command. This should generate a migration with an ``AlterField``
+ operation.
+
``RemoveField``
---------------