X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/21f878e8112cf1f9b732a6dbb77e70efa68a01aa..c973d0df626c8c3988689f9497883f0baaa29911:/apps/south/management/commands/migrate.py diff --git a/apps/south/management/commands/migrate.py b/apps/south/management/commands/migrate.py index d2d69982f..1cc2a2908 100644 --- a/apps/south/management/commands/migrate.py +++ b/apps/south/management/commands/migrate.py @@ -16,11 +16,20 @@ class Command(BaseCommand): help='Only runs or rolls back the migration specified, and none around it.'), make_option('--fake', action='store_true', dest='fake', default=False, help="Pretends to do the migrations, but doesn't actually execute them."), + + make_option('--db-dry-run', action='store_true', dest='db_dry_run', default=False, + help="Doesn't execute the SQL generated by the db methods, and doesn't store a record that the migration(s) occurred. Useful to test migrations before applying them."), ) + 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'), + ) help = "Runs migrations for all apps." - def handle(self, app=None, target=None, skip=False, merge=False, only=False, backwards=False, fake=False, **options): - + def handle(self, app=None, target=None, skip=False, merge=False, only=False, backwards=False, fake=False, db_dry_run=False, **options): + # Work out what the resolve mode is resolve_mode = merge and "merge" or (skip and "skip" or None) # Turn on db debugging @@ -46,10 +55,14 @@ class Command(BaseCommand): apps = [migration.get_app(app)] else: apps = migration.get_migrated_apps() + silent = options.get('verbosity', 0) == 0 for app in apps: migration.migrate_app( app, resolve_mode = resolve_mode, target_name = target, fake = fake, + db_dry_run = db_dry_run, + silent = silent, + load_inital_data = True, )