diff options
| author | Markus Holtermann <info@markusholtermann.eu> | 2015-03-29 16:59:35 +0200 |
|---|---|---|
| committer | Markus Holtermann <info@markusholtermann.eu> | 2015-03-30 16:31:20 +0200 |
| commit | c5cc332bf2a0b3ebfa3ad5d26c5b308de5e505be (patch) | |
| tree | 58e095966c96de38f50a96ab94386db80d9fa78a /django | |
| parent | dc27f3ee0c3eb9bb17d6cb764788eeaf73a371d7 (diff) | |
Fixed #24550 -- Added migration operation description to sqlmigrate output
Thanks Tim Graham for the review.
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/migrations/migration.py | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/django/db/migrations/migration.py b/django/db/migrations/migration.py index 1c3f560d6e..59f89afd08 100644 --- a/django/db/migrations/migration.py +++ b/django/db/migrations/migration.py @@ -91,13 +91,16 @@ 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("--") - continue + if not operation.reduces_to_sql: + continue # Save the state before the operation has run old_state = project_state.clone() operation.state_forwards(self.app_label, project_state) @@ -142,12 +145,14 @@ class Migration(object): # Phase 2 for operation, to_state, from_state in to_run: if collect_sql: + schema_editor.collected_sql.append("--") + 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: - schema_editor.collected_sql.append("--") - 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("--") continue if not schema_editor.connection.features.can_rollback_ddl and operation.atomic: # We're forcing a transaction on a non-transactional-DDL backend |
