David Gouldin  committed 22b6b08

Preserving db._constraint_cache between dry run and real migration to avoid constraint cache mutation during dry runs.

  • Participants
  • Parent commits 6843158

Comments (0)

Files changed (1)

File south/migration/

-from copy import copy
+from copy import copy, deepcopy
 from cStringIO import StringIO
 import datetime
 import inspect
                 print " - Migration '%s' is marked for no-dry-run." % migration
         south.db.db.dry_run = True
+        # preserve the constraint cache as it can be mutated by the dry run
+        constraint_cache = deepcopy(south.db.db._constraint_cache)
         if self._ignore_fail:
             south.db.db.debug, old_debug = False, south.db.db.debug
         pending_creates = south.db.db.get_pending_creates()
                 south.db.db.debug = old_debug
             south.db.db.dry_run = False
+            # restore the preserved constraint cache from before dry run was
+            # executed
+            south.db.db._constraint_cache = constraint_cache
     def run_migration(self, migration):