Commits

David Gouldin committed 22b6b08

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

Comments (0)

Files changed (1)

south/migration/migrators.py

-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
             return
         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.clear_run_data(pending_creates)
             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):
         try: