summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorGen1us2k <minkin.andrew@gmail.com>2015-12-15 19:06:33 +0600
committerTim Graham <timograham@gmail.com>2015-12-25 18:29:09 -0500
commit23cad094f6ee215f2fe3a1b16fb0c010c9683f74 (patch)
tree088d06dfbf594383a0cad2d0ba164921dd8362ab /docs/ref
parentdc1ef0ff2e4f7d6e5bef1a5ae4223cbea90044db (diff)
[1.9.x] Added docs example for manually creating a column with RunSQL.
Backport of a1d0c60fa05cbad2e5a25ec37e0afaf1b84c9302 from master
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/migration-operations.txt13
1 files changed, 12 insertions, 1 deletions
diff --git a/docs/ref/migration-operations.txt b/docs/ref/migration-operations.txt
index ed0400d244..de7c6cc9eb 100644
--- a/docs/ref/migration-operations.txt
+++ b/docs/ref/migration-operations.txt
@@ -237,7 +237,18 @@ equivalent to the SQL in terms of project state; for example, if you are
manually creating a column, you should pass in a list containing an ``AddField``
operation here so that the autodetector still has an up-to-date state of the
model (otherwise, when you next run ``makemigrations``, it won't see any
-operation that adds that field and so will try to run it again).
+operation that adds that field and so will try to run it again). For example::
+
+ migrations.RunSQL(
+ "ALTER TABLE musician ADD COLUMN name varchar(255) NOT NULL;",
+ state_operations=[
+ migrations.AddField(
+ 'musician',
+ 'name',
+ models.CharField(max_length=255),
+ ),
+ ],
+ )
The optional ``hints`` argument will be passed as ``**hints`` to the
:meth:`allow_migrate` method of database routers to assist them in making