Loading django/db/migrations/migration.py +14 −9 Original line number Diff line number Diff line Loading @@ -91,12 +91,15 @@ class Migration(object): for operation in self.operations: # If this operation cannot be represented as SQL, place a comment # there instead if collect_sql and not operation.reduces_to_sql: if collect_sql: schema_editor.collected_sql.append("--") schema_editor.collected_sql.append("-- MIGRATION NOW PERFORMS OPERATION THAT CANNOT BE " "WRITTEN AS SQL:") if not operation.reduces_to_sql: schema_editor.collected_sql.append( "-- MIGRATION NOW PERFORMS OPERATION THAT CANNOT BE WRITTEN AS SQL:" ) schema_editor.collected_sql.append("-- %s" % operation.describe()) schema_editor.collected_sql.append("--") if not operation.reduces_to_sql: continue # Save the state before the operation has run old_state = project_state.clone() Loading Loading @@ -142,12 +145,14 @@ class Migration(object): # Phase 2 for operation, to_state, from_state in to_run: if collect_sql: if not operation.reduces_to_sql: schema_editor.collected_sql.append("--") schema_editor.collected_sql.append("-- MIGRATION NOW PERFORMS OPERATION THAT CANNOT BE " "WRITTEN AS SQL:") if not operation.reduces_to_sql: schema_editor.collected_sql.append( "-- MIGRATION NOW PERFORMS OPERATION THAT CANNOT BE WRITTEN AS SQL:" ) schema_editor.collected_sql.append("-- %s" % operation.describe()) schema_editor.collected_sql.append("--") if not operation.reduces_to_sql: continue if not schema_editor.connection.features.can_rollback_ddl and operation.atomic: # We're forcing a transaction on a non-transactional-DDL backend Loading docs/intro/tutorial01.txt +10 −1 Original line number Diff line number Diff line Loading @@ -446,8 +446,8 @@ You should see something similar to the following: Migrations for 'polls': 0001_initial.py: - Create model Question - Create model Choice - Create model Question - Add field question to choice By running ``makemigrations``, you're telling Django that you've made Loading Loading @@ -476,16 +476,25 @@ readability): .. code-block:: sql BEGIN; -- -- Create model Choice -- CREATE TABLE "polls_choice" ( "id" serial NOT NULL PRIMARY KEY, "choice_text" varchar(200) NOT NULL, "votes" integer NOT NULL ); -- -- Create model Question -- CREATE TABLE "polls_question" ( "id" serial NOT NULL PRIMARY KEY, "question_text" varchar(200) NOT NULL, "pub_date" timestamp with time zone NOT NULL ); -- -- Add field question to choice -- ALTER TABLE "polls_choice" ADD COLUMN "question_id" integer NOT NULL; ALTER TABLE "polls_choice" ALTER COLUMN "question_id" DROP DEFAULT; CREATE INDEX "polls_choice_7aa0f6ee" ON "polls_choice" ("question_id"); Loading docs/ref/contrib/gis/tutorial.txt +3 −0 Original line number Diff line number Diff line Loading @@ -286,6 +286,9 @@ This command should produce the following output: .. code-block:: sql BEGIN; -- -- Create model WorldBorder -- CREATE TABLE "world_worldborder" ( "id" serial NOT NULL PRIMARY KEY, "name" varchar(50) NOT NULL, Loading docs/ref/django-admin.txt +6 −0 Original line number Diff line number Diff line Loading @@ -984,6 +984,12 @@ By default, the SQL created is for running the migration in the forwards direction. Pass ``--backwards`` to generate the SQL for unapplying the migration instead. .. versionchanged:: 1.9 To increase the readability of the overall SQL output the SQL code generated for each migration operation is preceded by the operation's description. sqlsequencereset <app_label app_label ...> ------------------------------------------ Loading docs/releases/1.9.txt +4 −0 Original line number Diff line number Diff line Loading @@ -152,6 +152,10 @@ Management Commands * The new :djadmin:`sendtestemail` command lets you send a test email to easily confirm that email sending through Django is working. * To increase the readability of the SQL code generated by :djadmin:`sqlmigrate`, the SQL code generated for each migration operation is preceded by the operation's description. Models ^^^^^^ Loading Loading
django/db/migrations/migration.py +14 −9 Original line number Diff line number Diff line Loading @@ -91,12 +91,15 @@ class Migration(object): for operation in self.operations: # If this operation cannot be represented as SQL, place a comment # there instead if collect_sql and not operation.reduces_to_sql: if collect_sql: schema_editor.collected_sql.append("--") schema_editor.collected_sql.append("-- MIGRATION NOW PERFORMS OPERATION THAT CANNOT BE " "WRITTEN AS SQL:") if not operation.reduces_to_sql: schema_editor.collected_sql.append( "-- MIGRATION NOW PERFORMS OPERATION THAT CANNOT BE WRITTEN AS SQL:" ) schema_editor.collected_sql.append("-- %s" % operation.describe()) schema_editor.collected_sql.append("--") if not operation.reduces_to_sql: continue # Save the state before the operation has run old_state = project_state.clone() Loading Loading @@ -142,12 +145,14 @@ class Migration(object): # Phase 2 for operation, to_state, from_state in to_run: if collect_sql: if not operation.reduces_to_sql: schema_editor.collected_sql.append("--") schema_editor.collected_sql.append("-- MIGRATION NOW PERFORMS OPERATION THAT CANNOT BE " "WRITTEN AS SQL:") if not operation.reduces_to_sql: schema_editor.collected_sql.append( "-- MIGRATION NOW PERFORMS OPERATION THAT CANNOT BE WRITTEN AS SQL:" ) schema_editor.collected_sql.append("-- %s" % operation.describe()) schema_editor.collected_sql.append("--") if not operation.reduces_to_sql: continue if not schema_editor.connection.features.can_rollback_ddl and operation.atomic: # We're forcing a transaction on a non-transactional-DDL backend Loading
docs/intro/tutorial01.txt +10 −1 Original line number Diff line number Diff line Loading @@ -446,8 +446,8 @@ You should see something similar to the following: Migrations for 'polls': 0001_initial.py: - Create model Question - Create model Choice - Create model Question - Add field question to choice By running ``makemigrations``, you're telling Django that you've made Loading Loading @@ -476,16 +476,25 @@ readability): .. code-block:: sql BEGIN; -- -- Create model Choice -- CREATE TABLE "polls_choice" ( "id" serial NOT NULL PRIMARY KEY, "choice_text" varchar(200) NOT NULL, "votes" integer NOT NULL ); -- -- Create model Question -- CREATE TABLE "polls_question" ( "id" serial NOT NULL PRIMARY KEY, "question_text" varchar(200) NOT NULL, "pub_date" timestamp with time zone NOT NULL ); -- -- Add field question to choice -- ALTER TABLE "polls_choice" ADD COLUMN "question_id" integer NOT NULL; ALTER TABLE "polls_choice" ALTER COLUMN "question_id" DROP DEFAULT; CREATE INDEX "polls_choice_7aa0f6ee" ON "polls_choice" ("question_id"); Loading
docs/ref/contrib/gis/tutorial.txt +3 −0 Original line number Diff line number Diff line Loading @@ -286,6 +286,9 @@ This command should produce the following output: .. code-block:: sql BEGIN; -- -- Create model WorldBorder -- CREATE TABLE "world_worldborder" ( "id" serial NOT NULL PRIMARY KEY, "name" varchar(50) NOT NULL, Loading
docs/ref/django-admin.txt +6 −0 Original line number Diff line number Diff line Loading @@ -984,6 +984,12 @@ By default, the SQL created is for running the migration in the forwards direction. Pass ``--backwards`` to generate the SQL for unapplying the migration instead. .. versionchanged:: 1.9 To increase the readability of the overall SQL output the SQL code generated for each migration operation is preceded by the operation's description. sqlsequencereset <app_label app_label ...> ------------------------------------------ Loading
docs/releases/1.9.txt +4 −0 Original line number Diff line number Diff line Loading @@ -152,6 +152,10 @@ Management Commands * The new :djadmin:`sendtestemail` command lets you send a test email to easily confirm that email sending through Django is working. * To increase the readability of the SQL code generated by :djadmin:`sqlmigrate`, the SQL code generated for each migration operation is preceded by the operation's description. Models ^^^^^^ Loading