Commits

charettes committed 567b1ca

Make sure transaction database operations are using the current db alias

Comments (0)

Files changed (1)

south/db/generic.py

         """
         if self.dry_run:
             self.pending_transactions += 1
-        transaction.commit_unless_managed()
-        transaction.enter_transaction_management()
-        transaction.managed(True)
+        transaction.commit_unless_managed(using=self.db_alias)
+        transaction.enter_transaction_management(using=self.db_alias)
+        transaction.managed(True, using=self.db_alias)
 
     def commit_transaction(self):
         """
         """
         if self.dry_run:
             return
-        transaction.commit()
-        transaction.leave_transaction_management()
+        transaction.commit(using=self.db_alias)
+        transaction.leave_transaction_management(using=self.db_alias)
 
     def rollback_transaction(self):
         """
         """
         if self.dry_run:
             self.pending_transactions -= 1
-        transaction.rollback()
-        transaction.leave_transaction_management()
+        transaction.rollback(using=self.db_alias)
+        transaction.leave_transaction_management(using=self.db_alias)
 
     def rollback_transactions_dry_run(self):
         """
         if not self.dry_run:
             return
         while self.pending_transactions > 0:
-            self.rollback_transaction()
-        if transaction.is_dirty():
+            self.rollback_transaction(using=self.db_alias)
+        if transaction.is_dirty(using=self.db_alias):
             # Force an exception, if we're still in a dirty transaction.
             # This means we are missing a COMMIT/ROLLBACK.
-            transaction.leave_transaction_management()
+            transaction.leave_transaction_management(using=self.db_alias)
 
     def send_create_signal(self, app_label, model_names):
         self.pending_create_signals.append((app_label, model_names))