Dodanie aplikacji do umieszczania pomocniczych materiałów dla nauczycieli.
[wolnelektury.git] / apps / south / management / commands / migrate.py
index d2d6998..1cc2a29 100644 (file)
@@ -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."),
             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."
 
     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
         # 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()
             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,
         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,
             )
             )