Modify ↓
Ticket #936 (closed defect: fixed)
(patch) duplicate dry-run output if not south.db.db.has_ddl_transactions
| Reported by: | david.lowe@… | Owned by: | andrew |
|---|---|---|---|
| Priority: | minor | Milestone: | |
| Component: | migrations | Version: | 0.7.3 |
| Keywords: | Cc: |
Description
In cases where the db doesn't support DDL transactions, passing --db-dry-run on the command-line will cause *two* dry-run passes, because the implicit dry-run doesn't get skipped.
The patch is somewhat complicated by the fact that, as far as I could tell, there's no existing way to introspect whether the current migrator is, in fact, already wrapped in a dry-run. So I added one... Anyway, here ya go:
--- migrators.py.original 2011-10-24 23:56:21.000000000 +0000
+++ migrators.py 2011-10-25 00:00:21.000000000 +0000
@@ -91,11 +91,13 @@
def run(self, migration):
# Get the correct ORM.
south.db.db.current_orm = self.orm(migration)
- # If the database doesn't support running DDL inside a transaction
- # *cough*MySQL*cough* then do a dry run first.
- if not south.db.db.has_ddl_transactions:
- dry_run = DryRunMigrator(migrator=self, ignore_fail=False)
- dry_run.run_migration(migration)
+ # If we're not already in a dry run, and the database doesn't support
+ # running DDL inside a transaction, *cough*MySQL*cough* then do a dry
+ # run first.
+ if not isinstance(getattr(self, '_wrapper', self), DryRunMigrator):
+ if not south.db.db.has_ddl_transactions:
+ dry_run = DryRunMigrator(migrator=self, ignore_fail=False)
+ dry_run.run_migration(migration)
return self.run_migration(migration)
def done_migrate(self, migration, database):
@@ -138,6 +140,7 @@
for k in self.__class__.__dict__.iterkeys()
if not k.startswith('__')])
self._migrator.__dict__.update(attributes)
+ self._migrator.__dict__['_wrapper'] = self
def __getattr__(self, name):
return getattr(self._migrator, name)
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

Fixed in [a13ccb4e7a09].