Commits

Andrew Godwin committed 3803313

Fix #519: convert_to_south didn't take a few useful options.

Comments (0)

Files changed (1)

south/management/commands/convert_to_south.py

     if '--verbosity' not in [opt.get_opt_string() for opt in BaseCommand.option_list]:
         option_list += (
             make_option('--verbosity', action='store', dest='verbosity', default='1',
-            type='choice', choices=['0', '1', '2'],
-            help='Verbosity level; 0=minimal output, 1=normal output, 2=all output'),
+                type='choice', choices=['0', '1', '2'],
+                help='Verbosity level; 0=minimal output, 1=normal output, 2=all output'),
+            make_option('--delete-ghost-migrations', action='store_true', dest='delete_ghosts', default=False,
+                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."), 
         )
 
     help = "Quickly converts the named application to use South if it is currently using syncdb."
         Migrations._clear_cache()
         
         # Now, migrate
-        management.call_command("migrate", app, "0001", fake=True, verbosity=verbosity)
+        management.call_command(
+            "migrate",
+            app,
+            "0001",
+            fake=True,
+            verbosity=verbosity,
+            ignore_ghosts=options.get("ignore_ghosts", False),
+            delete_ghosts=options.get("delete_ghosts", False),
+        )
         
         print 
         print "App '%s' converted. Note that South assumed the application's models matched the database" % app