Anonymous avatar Anonymous committed fe7d447

accept and respect --noinput on migrate; fixes #440

Comments (0)

Files changed (4)

south/db/generic.py

         self.pending_create_signals.append((app_label, model_names))
 
 
-    def send_pending_create_signals(self):
+    def send_pending_create_signals(self, verbosity=0, interactive=False):
         # Group app_labels together
         signals = SortedDict()
         for (app_label, model_names) in self.pending_create_signals:
                 signals[app_label] = list(model_names)
         # Send only one signal per app.
         for (app_label, model_names) in signals.iteritems():
-            self.really_send_create_signal(app_label, list(set(model_names)))
+            self.really_send_create_signal(app_label, list(set(model_names)),
+                                           verbosity=verbosity,
+                                           interactive=interactive)
         self.pending_create_signals = []
 
 
-    def really_send_create_signal(self, app_label, model_names):
+    def really_send_create_signal(self, app_label, model_names,
+                                  verbosity=0, interactive=False):
         """
         Sends a post_syncdb signal for the model specified.
 
                 created_models.append(model)
 
         if created_models:
-            # syncdb defaults -- perhaps take these as options?
-            verbosity = 1
-            interactive = True
 
             if hasattr(dispatcher, "send"):
                 # Older djangos

south/management/commands/migrate.py

             help="Tells South to delete any 'ghost' migrations (ones in the database but not on disk)."),
         make_option('--ignore-ghost-migrations', action='store_true', dest='ignore_ghosts', default=False,
             help="Tells South to ignore any 'ghost' migrations (ones in the database but not on disk) and continue to apply new migrations."),
+        make_option('--noinput', action='store_false', dest='interactive', default=True,
+            help='Tells Django to NOT prompt the user for input of any kind.'),
         make_option('--database', action='store', dest='database',
             default=DEFAULT_DB_ALIAS, help='Nominates a database to synchronize. '
                 'Defaults to the "default" database.'),
                     fake = fake,
                     db_dry_run = db_dry_run,
                     verbosity = int(options.get('verbosity', 0)),
+                    interactive = options.get('interactive', True),
                     load_initial_data = not options.get('no_initial_data', False),
                     merge = merge,
                     skip = skip,

south/migration/__init__.py

             backwards = migration_before_here.backwards_plan
     return forwards, backwards
 
-def get_direction(target, applied, migrations, verbosity):
+def get_direction(target, applied, migrations, verbosity, interactive):
     # Get the forwards and reverse dependencies for this target
     forwards, backwards = get_dependencies(target, migrations)
     # Is the whole forward branch applied?
         # the forwards trace, we just need to go forwards to our
         # target (and check for badness)
         problems = forwards_problems(forwards, applied, verbosity)
-        direction = Forwards(verbosity=verbosity)
+        direction = Forwards(verbosity=verbosity, interactive=interactive)
     if not problems:
         # What about the whole backward trace then?
         backwards = backwards()
             # all the higher migrations) then we need to go backwards
             workplan = to_unapply(backwards, applied)
             problems = backwards_problems(backwards, applied, verbosity)
-            direction = Backwards(verbosity=verbosity)
+            direction = Backwards(verbosity=verbosity, interactive=interactive)
     return direction, problems, workplan
 
 def get_migrator(direction, db_dry_run, fake, load_initial_data):
         direction = LoadInitialDataMigrator(migrator=direction)
     return direction
 
-def migrate_app(migrations, target_name=None, merge=False, fake=False, db_dry_run=False, yes=False, verbosity=0, load_initial_data=False, skip=False, database=DEFAULT_DB_ALIAS, delete_ghosts=False, ignore_ghosts=False):
+def migrate_app(migrations, target_name=None, merge=False, fake=False, db_dry_run=False, yes=False, verbosity=0, load_initial_data=False, skip=False, database=DEFAULT_DB_ALIAS, delete_ghosts=False, ignore_ghosts=False, interactive=False):
     app_label = migrations.app_label()
 
     verbosity = int(verbosity)
         print "Running migrations for %s:" % app_label
     
     # Get the forwards and reverse dependencies for this target
-    direction, problems, workplan = get_direction(target, applied,
-                                                  migrations, verbosity)
+    direction, problems, workplan = get_direction(target, applied, migrations,
+                                                  verbosity, interactive)
     if problems and not (merge or skip):
         raise exceptions.InconsistentMigrationHistory(problems)
     

south/migration/migrators.py

 
 
 class Migrator(object):
-    def __init__(self, verbosity=0):
+    def __init__(self, verbosity=0, interactive=False):
         self.verbosity = int(verbosity)
+        self.interactive = bool(interactive)
 
     @staticmethod
     def title(target):
                     return False
         finally:
             # Call any pending post_syncdb signals
-            south.db.db.send_pending_create_signals()
+            south.db.db.send_pending_create_signals(verbosity=self.verbosity,
+                                                    interactive=self.interactive)
         return True
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.