Skip to content
This repository

my proposal to solve the bug #22 #23

Closed
wants to merge 1 commit into from

3 participants

Marcin Nowak Patrick Altman Brian Rosner
Marcin Nowak

No description provided.

Brian Rosner
Collaborator

The previous behavior was not a bug and very intentional. This changes the old behavior in a backwards incompatible way. While I understand why this is done, it needs much more thought. I'll need to think about this some more.

Patrick Altman
Owner

@marcinn after careful consideration and upon seeing a different implementation we have decided to bring back transactional support by merging in #44, thank you for bringing this issue back up and even though your PR was not merged the contribution was/is appreciated.

Patrick Altman paltman closed this April 06, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Apr 27, 2011
Marcin Nowak fixing #22: bug in migrations execution 120128c
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 26 additions and 23 deletions. Show diff stats Hide diff stats

  1. 49  nashvegas/management/commands/upgradedb.py
49  nashvegas/management/commands/upgradedb.py
@@ -165,8 +165,9 @@ def execute_migrations(self, show_traceback=False):
165 165
         
166 166
         created_models = set()
167 167
         
168  
-        try:
169  
-            for migration in migrations:
  168
+        for migration in migrations:
  169
+            iteration_models = set()
  170
+            try:
170 171
                 migration_path = os.path.join(self.path, migration)
171 172
                 fp = open(migration_path, "rb")
172 173
                 lines = fp.readlines()
@@ -194,7 +195,7 @@ def execute_migrations(self, show_traceback=False):
194 195
                     
195 196
                     for l in lines:
196 197
                         if l.startswith("### New Model: "):
197  
-                            created_models.add(
  198
+                            iteration_models.add(
198 199
                                 get_model(
199 200
                                     *l.replace("### New Model: ", "").strip().split(".")
200 201
                                 ) 
@@ -221,26 +222,28 @@ def execute_migrations(self, show_traceback=False):
221 222
                     content=content,
222 223
                     scm_version=self._get_rev(migration_path)
223 224
                 )
224  
-            sys.stdout.write("Emitting post sync signal.\n")
225  
-            emit_post_sync_signal(
226  
-                created_models,
227  
-                self.verbosity,
228  
-                self.interactive,
229  
-                self.db
230  
-            )
231  
-            sys.stdout.write("Running loaddata for initial_data fixtures.\n")
232  
-            call_command(
233  
-                "loaddata",
234  
-                "initial_data",
235  
-                verbosity=self.verbosity,
236  
-                database=self.db
237  
-            )
238  
-        except Exception:
239  
-            transaction.rollback(using=self.db)
240  
-            sys.stdout.write("Rolled back all migrations.\n")
241  
-            raise
242  
-        else:
243  
-            transaction.commit(using=self.db)
  225
+            except Exception:
  226
+                transaction.rollback(using=self.db)
  227
+                sys.stdout.write("Rolled back all migrations.\n")
  228
+                raise
  229
+            else:
  230
+                created_models = created_models.union(iteration_models)
  231
+                transaction.commit(using=self.db)
  232
+
  233
+        sys.stdout.write("Emitting post sync signal.\n")
  234
+        emit_post_sync_signal(
  235
+            created_models,
  236
+            self.verbosity,
  237
+            self.interactive,
  238
+            self.db
  239
+        )
  240
+        sys.stdout.write("Running loaddata for initial_data fixtures.\n")
  241
+        call_command(
  242
+            "loaddata",
  243
+            "initial_data",
  244
+            verbosity=self.verbosity,
  245
+            database=self.db
  246
+        )
244 247
     
245 248
     def seed_migrations(self, stop_at=None):
246 249
         # @@@ the command-line interface needs to be re-thinked
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.