当前位置: 首页>>代码示例>>Python>>正文


Python migration.migrate_app函数代码示例

本文整理汇总了Python中south.migration.migrate_app函数的典型用法代码示例。如果您正苦于以下问题:Python migrate_app函数的具体用法?Python migrate_app怎么用?Python migrate_app使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了migrate_app函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_migration_merge_forwards

 def test_migration_merge_forwards(self):
     migration.MigrationHistory.objects.all().delete()
     app = migration.get_app("fakeapp")
     
     # We should start with no migrations
     self.assertEqual(list(migration.MigrationHistory.objects.all()), [])
     
     # Insert one in the wrong order
     migration.MigrationHistory.objects.create(
         app_name = "fakeapp",
         migration = "0002_eggs",
         applied = datetime.datetime.now(),
     )
     
     # Did it go in?
     self.assertListEqual(
         (
             (u"fakeapp", u"0002_eggs"),
         ),
         migration.MigrationHistory.objects.values_list("app_name", "migration"),
     )
     
     # Apply them normally
     tree = migration.dependency_tree()
     try:
         # Redirect the error it will print to nowhere
         stdout, sys.stdout = sys.stdout, StringIO.StringIO()
         migration.migrate_app(app, tree, target_name=None, resolve_mode=None, fake=False, verbosity=0)
         sys.stdout = stdout
     except SystemExit:
         pass
     
     # Nothing should have changed (no merge mode!)
     self.assertListEqual(
         (
             (u"fakeapp", u"0002_eggs"),
         ),
         migration.MigrationHistory.objects.values_list("app_name", "migration"),
     )
     
     # Apply with merge
     migration.migrate_app(app, tree, target_name=None, resolve_mode="merge", fake=False, verbosity=0)
     
     # We should finish with all migrations
     self.assertListEqual(
         (
             (u"fakeapp", u"0001_spam"),
             (u"fakeapp", u"0002_eggs"),
             (u"fakeapp", u"0003_alter_spam"),
         ),
         migration.MigrationHistory.objects.values_list("app_name", "migration"),
     )
     
     # Now roll them backwards
     migration.migrate_app(app, tree, target_name="0002", resolve_mode=None, fake=False, verbosity=0)
     migration.migrate_app(app, tree, target_name="0001", resolve_mode=None, fake=True, verbosity=0)
     migration.migrate_app(app, tree, target_name="zero", resolve_mode=None, fake=False, verbosity=0)
     
     # Finish with none
     self.assertEqual(list(migration.MigrationHistory.objects.all()), [])
开发者ID:fdl06,项目名称:medianav,代码行数:60,代码来源:logic.py

示例2: test_migration_merge_forwards

    def test_migration_merge_forwards(self):
        MigrationHistory.objects.all().delete()
        migrations = Migrations("fakeapp")

        # We should start with no migrations
        self.assertEqual(list(MigrationHistory.objects.all()), [])

        # Insert one in the wrong order
        MigrationHistory.objects.create(app_name="fakeapp", migration="0002_eggs", applied=datetime.datetime.now())

        # Did it go in?
        self.assertListEqual(
            ((u"fakeapp", u"0002_eggs"),), MigrationHistory.objects.values_list("app_name", "migration")
        )

        # Apply them normally
        self.assertRaises(
            exceptions.InconsistentMigrationHistory, migrate_app, migrations, target_name=None, fake=False
        )
        self.assertRaises(
            exceptions.InconsistentMigrationHistory, migrate_app, migrations, target_name="zero", fake=False
        )
        try:
            migrate_app(migrations, target_name=None, fake=False)
        except exceptions.InconsistentMigrationHistory, e:
            self.assertEqual([(migrations["0002_eggs"], [migrations["0001_spam"]])], e.problems)
开发者ID:notanumber,项目名称:south,代码行数:26,代码来源:logic.py

示例3: test_apply_migrations

 def test_apply_migrations(self):
     migration.MigrationHistory.objects.all().delete()
     app = migration.get_app("fakeapp")
     
     # We should start with no migrations
     self.assertEqual(list(migration.MigrationHistory.objects.all()), [])
     
     # Apply them normally
     tree = migration.dependency_tree()
     migration.migrate_app(app, tree, target_name=None, resolve_mode=None, fake=False, verbosity=0)
     
     # We should finish with all migrations
     self.assertListEqual(
         (
             (u"fakeapp", u"0001_spam"),
             (u"fakeapp", u"0002_eggs"),
             (u"fakeapp", u"0003_alter_spam"),
         ),
         migration.MigrationHistory.objects.values_list("app_name", "migration"),
     )
     
     # Now roll them backwards
     migration.migrate_app(app, tree, target_name="zero", resolve_mode=None, fake=False, verbosity=0)
     
     # Finish with none
     self.assertEqual(list(migration.MigrationHistory.objects.all()), [])
开发者ID:fdl06,项目名称:medianav,代码行数:26,代码来源:logic.py

示例4: test_migration_merge_forwards

 def test_migration_merge_forwards(self):
     
     app = migration.get_app("fakeapp")
     
     # We should start with no migrations
     self.assertEqual(list(migration.MigrationHistory.objects.all()), [])
     
     # Insert one in the wrong order
     migration.MigrationHistory.objects.create(
         app_name = "fakeapp",
         migration = "0002_eggs",
         applied = datetime.datetime.now(),
     )
     
     # Did it go in?
     self.assertListEqual(
         (
             (u"fakeapp", u"0002_eggs"),
         ),
         migration.MigrationHistory.objects.values_list("app_name", "migration"),
     )
     
     # Apply them normally
     try:
         migration.migrate_app(app, target_name=None, resolve_mode=None, fake=False, silent=True)
     except SystemExit:
         pass
     
     # Nothing should have changed (no merge mode!)
     self.assertListEqual(
         (
             (u"fakeapp", u"0002_eggs"),
         ),
         migration.MigrationHistory.objects.values_list("app_name", "migration"),
     )
     
     # Apply with merge
     migration.migrate_app(app, target_name=None, resolve_mode="merge", fake=False, silent=True)
     
     # We should finish with all migrations
     self.assertListEqual(
         (
             (u"fakeapp", u"0001_spam"),
             (u"fakeapp", u"0002_eggs"),
             (u"fakeapp", u"0003_alter_spam"),
         ),
         migration.MigrationHistory.objects.values_list("app_name", "migration"),
     )
     
     # Now roll them backwards
     migration.migrate_app(app, target_name="0002", resolve_mode=None, fake=False, silent=True)
     migration.migrate_app(app, target_name="0001", resolve_mode=None, fake=True, silent=True)
     migration.migrate_app(app, target_name="zero", resolve_mode=None, fake=False, silent=True)
     
     # Finish with none
     self.assertEqual(list(migration.MigrationHistory.objects.all()), [])
开发者ID:artemrizhov,项目名称:itcm,代码行数:56,代码来源:logic.py

示例5: test_alter_column_null

    def test_alter_column_null(self):
        def null_ok():
            from django.db import connection, transaction
            # the DBAPI introspection module fails on postgres NULLs.
            cursor = connection.cursor()
            try:
                cursor.execute("INSERT INTO southtest_spam (id, weight, expires, name) VALUES (100, 10.1, now(), NULL);")
            except:
                transaction.rollback()
                return False
            else:
                cursor.execute("DELETE FROM southtest_spam")
                transaction.commit()
                return True
        
        app = migration.get_app("fakeapp")
        tree = migration.dependency_tree()
        self.assertEqual(list(migration.MigrationHistory.objects.all()), [])
        
        # by default name is NOT NULL
        migration.migrate_app(app, tree, target_name="0002", resolve_mode=None, fake=False, verbosity=0)
        self.failIf(null_ok())
        
        # after 0003, it should be NULL
        migration.migrate_app(app, tree, target_name="0003", resolve_mode=None, fake=False, verbosity=0)
        self.assert_(null_ok())

        # make sure it is NOT NULL again
        migration.migrate_app(app, tree, target_name="0002", resolve_mode=None, fake=False, verbosity=0)
        self.failIf(null_ok(), 'name not null after migration')
        
        # finish with no migrations, otherwise other tests fail...
        migration.migrate_app(app, tree, target_name="zero", resolve_mode=None, fake=False, verbosity=0)
        self.assertEqual(list(migration.MigrationHistory.objects.all()), [])
开发者ID:fdl06,项目名称:medianav,代码行数:34,代码来源:logic.py

示例6: handle

    def handle(self, *args, **options):
        verbosity = int(options.get('verbosity', '1'))
        assert django.VERSION < (1, 7)
        from south import migration
        from south.models import MigrationHistory

        try:
            MigrationHistory.objects.count()
        except OperationalError:
            return

        apps  = list(migration.all_migrations())
        applied_migrations = MigrationHistory.objects.filter(app_name__in=[app.app_label() for app in apps])
        applied_migrations = ['%s.%s' % (mi.app_name, mi.migration) for mi in applied_migrations]

        for app in apps:
            for app_migration in app:
                migration_name = '%s.%s' % (app_migration.app_label(), app_migration.name())
                
                print migration_name, bool(migration_name in applied_migrations)
                if migration_name not in applied_migrations:
                    result = migration.migrate_app(
                        app,
                        app_migration.name(),
                        verbosity = verbosity,
                        db_dry_run = True,
                    )
                    if result is False:
                        sys.exit('Migration %s failed.' % migration_name)
开发者ID:cchurch,项目名称:django-northward,代码行数:29,代码来源:migrate_northward.py

示例7: test_alter_column_null

    def test_alter_column_null(self):
        
        def null_ok():
            from django.db import connection, transaction
            # the DBAPI introspection module fails on postgres NULLs.
            cursor = connection.cursor()
        
            # SQLite has weird now()
            if db.backend_name == "sqlite3":
                now_func = "DATETIME('NOW')"
            else:
                now_func = "NOW()"
            
            try:
                cursor.execute("INSERT INTO southtest_spam (id, weight, expires, name) VALUES (100, 10.1, %s, NULL);" % now_func)
            except:
                transaction.rollback()
                return False
            else:
                cursor.execute("DELETE FROM southtest_spam")
                transaction.commit()
                return True

        MigrationHistory.objects.all().delete()
        migrations = Migrations("fakeapp")
        
        # by default name is NOT NULL
        migrate_app(migrations, target_name="0002", fake=False)
        self.failIf(null_ok())
        self.assertListEqual(
            ((u"fakeapp", u"0001_spam"),
             (u"fakeapp", u"0002_eggs"),),
            MigrationHistory.objects.values_list("app_name", "migration"),
        )
        
        # after 0003, it should be NULL
        migrate_app(migrations, target_name="0003", fake=False)
        self.assert_(null_ok())
        self.assertListEqual(
            ((u"fakeapp", u"0001_spam"),
             (u"fakeapp", u"0002_eggs"),
             (u"fakeapp", u"0003_alter_spam"),),
            MigrationHistory.objects.values_list("app_name", "migration"),
        )

        # make sure it is NOT NULL again
        migrate_app(migrations, target_name="0002", fake=False)
        self.failIf(null_ok(), 'name not null after migration')
        self.assertListEqual(
            ((u"fakeapp", u"0001_spam"),
             (u"fakeapp", u"0002_eggs"),),
            MigrationHistory.objects.values_list("app_name", "migration"),
        )
        
        # finish with no migrations, otherwise other tests fail...
        migrate_app(migrations, target_name="zero", fake=False)
        self.assertEqual(list(MigrationHistory.objects.all()), [])
开发者ID:amyth,项目名称:django-south,代码行数:57,代码来源:logic.py

示例8: handle

    def handle(self, app=None, target=None, skip=False, merge=False, backwards=False, fake=False, db_dry_run=False,
               show_list=False, show_changes=False, database=DEFAULT_DB_ALIAS, delete_ghosts=False, ignore_ghosts=False, **options):

        # NOTE: THIS IS DUPLICATED FROM django.core.management.commands.syncdb
        # This code imports any module named 'management' in INSTALLED_APPS.
        # The 'management' module is the preferred way of listening to post_syncdb
        # signals, and since we're sending those out with create_table migrations,
        # we need apps to behave correctly.
        for app_name in settings.INSTALLED_APPS:
            try:
                import_module('.management', app_name)
            except ImportError as exc:
                msg = exc.args[0]
                if not msg.startswith('No module named') or 'management' not in msg:
                    raise
        # END DJANGO DUPE CODE

        # if all_apps flag is set, shift app over to target
        if options.get('all_apps', False):
            target = app
            app = None

        # Migrate each app
        if app:
            try:
                apps = [Migrations(app)]
            except NoMigrations:
                print("The app '%s' does not appear to use migrations." % app)
                print("./manage.py migrate " + self.args)
                return
        else:
            apps = list(migration.all_migrations())

        # Do we need to show the list of migrations?
        if show_list and apps:
            list_migrations(apps, database, **options)

        if show_changes and apps:
            show_migration_changes(apps)

        if not (show_list or show_changes):

            for app in apps:
                result = migration.migrate_app(
                    app,
                    target_name=target,
                    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,
                    database=database,
                    delete_ghosts=delete_ghosts,
                    ignore_ghosts=ignore_ghosts,
                )
                if result is False:
                    sys.exit(1)  # Migration failed, so the command fails.
开发者ID:NuttasitBoonwat,项目名称:sentry,代码行数:59,代码来源:migrate.py

示例9: test_apply_migrations

    def test_apply_migrations(self):
        MigrationHistory.objects.all().delete()
        migrations = Migrations("fakeapp")

        # We should start with no migrations
        self.assertEqual(list(MigrationHistory.objects.all()), [])

        # Apply them normally
        migrate_app(migrations, target_name=None, fake=False, load_initial_data=True)

        # We should finish with all migrations
        self.assertListEqual(
            ((u"fakeapp", u"0001_spam"), (u"fakeapp", u"0002_eggs"), (u"fakeapp", u"0003_alter_spam")),
            MigrationHistory.objects.values_list("app_name", "migration"),
        )

        # Now roll them backwards
        migrate_app(migrations, target_name="zero", fake=False)

        # Finish with none
        self.assertEqual(list(MigrationHistory.objects.all()), [])
开发者ID:notanumber,项目名称:south,代码行数:21,代码来源:logic.py

示例10: test_apply_migrations

 def test_apply_migrations(self):
     
     app = migration.get_app("fakeapp")
     
     # We should start with no migrations
     self.assertEqual(list(migration.MigrationHistory.objects.all()), [])
     
     # Apply them normally
     migration.migrate_app(app, target_name=None, resolve_mode=None, fake=False, silent=True)
     
     # We should finish with all migrations
     self.assertListEqual(
         (
             (u"fakeapp", u"0001_spam"),
             (u"fakeapp", u"0002_eggs"),
         ),
         migration.MigrationHistory.objects.values_list("app_name", "migration"),
     )
     
     # Now roll them backwards
     migration.migrate_app(app, target_name="zero", resolve_mode=None, fake=False, silent=True)
     
     # Finish with none
     self.assertEqual(list(migration.MigrationHistory.objects.all()), [])
开发者ID:akaihola,项目名称:django-south,代码行数:24,代码来源:logic.py

示例11: begin

    def begin(self):
        """
        Initialize the test environment then create the test database
        and switch the connection over to that database.
        """
        import django
        from django.conf import settings
        from django.db import connection
        from django.core import management
        from django.test.utils import setup_test_environment

        use_south = 'south' in settings.INSTALLED_APPS
        if use_south:
            from south import migration
            from south.hacks import hacks

        try:
            self.original_db_name = settings.DATABASE_NAME
        except AttributeError:  # Django > 1.2
            self.original_db_name = settings.DATABASES['default']['NAME']

        try:
            django.setup()  # Django >= 1.7
        except AttributeError:
            pass
        setup_test_environment()

        if use_south:
            management.get_commands()
            hacks.patch_flush_during_test_db_creation()

        connection.creation.create_test_db(self.verbosity)

        if use_south:
            for app in migration.all_migrations():
                migration.migrate_app(app, verbosity=self.verbosity)
开发者ID:Fantomas42,项目名称:nose-sfd,代码行数:36,代码来源:sfd.py

示例12: test_alter_column_null

    def test_alter_column_null(self):
        
        def null_ok(eat_exception=True):
            from django.db import connection, transaction
            # the DBAPI introspection module fails on postgres NULLs.
            cursor = connection.cursor()
        
            # SQLite has weird now()
            if db.backend_name == "sqlite3":
                now_func = "DATETIME('NOW')"
            # So does SQLServer... should we be using a backend attribute?
            elif db.backend_name == "pyodbc":
                now_func = "GETDATE()"
            elif db.backend_name == "oracle":
                now_func = "SYSDATE"
            else:
                now_func = "NOW()"
            
            try:
                if db.backend_name == "pyodbc":
                    cursor.execute("SET IDENTITY_INSERT southtest_spam ON;")
                cursor.execute("INSERT INTO southtest_spam (id, weight, expires, name) VALUES (100, NULL, %s, 'whatever');" % now_func)
            except:
                if eat_exception:
                    transaction.rollback()
                    return False
                else:
                    raise
            else:
                cursor.execute("DELETE FROM southtest_spam")
                transaction.commit()
                return True

        MigrationHistory.objects.all().delete()
        migrations = Migrations("fakeapp")
        
        # by default name is NOT NULL
        migrate_app(migrations, target_name="0002", fake=False)
        self.failIf(null_ok())
        self.assertListEqual(
            (("fakeapp", "0001_spam"),
             ("fakeapp", "0002_eggs"),),
            MigrationHistory.objects.values_list("app_name", "migration"),
        )
        
        # after 0003, it should be NULL
        migrate_app(migrations, target_name="0003", fake=False)
        self.assert_(null_ok(False))
        self.assertListEqual(
            (("fakeapp", "0001_spam"),
             ("fakeapp", "0002_eggs"),
             ("fakeapp", "0003_alter_spam"),),
            MigrationHistory.objects.values_list("app_name", "migration"),
        )

        # make sure it is NOT NULL again
        migrate_app(migrations, target_name="0002", fake=False)
        self.failIf(null_ok(), 'weight not null after migration')
        self.assertListEqual(
            (("fakeapp", "0001_spam"),
             ("fakeapp", "0002_eggs"),),
            MigrationHistory.objects.values_list("app_name", "migration"),
        )
        
        # finish with no migrations, otherwise other tests fail...
        migrate_app(migrations, target_name="zero", fake=False)
        self.assertEqual(list(MigrationHistory.objects.all()), [])
开发者ID:adamjberg,项目名称:finna-be-octo-ninja,代码行数:67,代码来源:logic.py

示例13: list

            print "./manage.py migrate " + self.args
            return
    else:
        apps = list(migration.all_migrations())
        
    # Do we need to show the list of migrations?
    if show_list and apps:
        list_migrations(apps, database, **options)
        
    if not show_list:
            
        for app in apps:
            result = migration.migrate_app(
                app,
                target_name = target,
                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,
                database = database,
                delete_ghosts = delete_ghosts,
                ignore_ghosts = ignore_ghosts,
            )
            if result is False:
                sys.exit(1) # Migration failed, so the command fails.

Command.handle = new_handle
开发者ID:debon,项目名称:comt,代码行数:30,代码来源:monkey_patches.py

示例14: handle


#.........这里部分代码省略.........
            for action_name, params in change_source.get_changes():
                # Run the correct Action class
                try:
                    action_class = getattr(actions, action_name)
                except AttributeError:
                    raise ValueError(
                        "Invalid action name from source: %s" % action_name)
                else:
                    action = action_class(**params)
                    action.add_forwards(forwards_actions)
                    action.add_backwards(backwards_actions)
                    print(action.console_line(), file=sys.stderr)

        # Nowt happen? That's not good for --auto.
        if auto and not forwards_actions:
            self.error("Nothing seems to have changed.")

        # Work out which apps to freeze
        apps_to_freeze = self.calc_frozen_apps(migrations, freeze_list)

        # So, what's in this file, then?
        file_contents = MIGRATION_TEMPLATE % {
            "forwards": "\n".join(forwards_actions or ["        pass"]),
            "backwards": "\n".join(backwards_actions or ["        pass"]),
            "frozen_models": freezer.freeze_apps_to_string(apps_to_freeze),
            "complete_apps": apps_to_freeze and "complete_apps = [%s]" % (
                ", ".join(map(repr, apps_to_freeze))) or ""
        }

        # Custom Bluebottle
        # We find and replace the base apps with our mapped models
        for model in MODEL_MAP:
            model_map = MODEL_MAP[model]
            mapping = {
                'u"orm[\'{0}\']"'.format(model_map[
                                             'model']): '"orm[\'{0}\']".format(MODEL_MAP[\'{1}\'][\'model\'])'.format(
                    '{0}', model),
                'u\'{0}\''.format(
                    model_map['table']): 'MODEL_MAP[\'{0}\'][\'table\']'.format(
                    model),
                'u\'{0}\''.format(model_map[
                                      'model_lower']): 'MODEL_MAP[\'{0}\'][\'model_lower\']'.format(
                    model),
                'u\'{0}\''.format(
                    model_map['app']): 'MODEL_MAP[\'{0}\'][\'app\']'.format(
                    model),
                '[\'{0}\']'.format(
                    model_map['app']): '[MODEL_MAP[\'{0}\'][\'app\']]'.format(
                    model),
                'to=orm[\'{0}\']'.format(model_map[
                                             'model']): 'to=orm[MODEL_MAP[\'{0}\'][\'model\']]'.format(
                    model),
                '\'object_name\': \'{0}\''.format(model_map[
                                                      'class']): '\'object_name\': MODEL_MAP[\'{0}\'][\'class\']'.format(
                    model)
            }
            file_contents = reduce(lambda x, y: x.replace(y, mapping[y]),
                                   mapping, file_contents)
        # End Custom Bluebottle

        # Deal with update mode as late as possible, avoid a rollback as long
        # as something else can go wrong.
        if update:
            last_migration = migrations[-1]
            if MigrationHistory.objects.filter(applied__isnull=False,
                                               app_name=app,
                                               migration=last_migration.name()):
                print(
                    "Migration to be updated, %s, is already applied, rolling it back now..." % last_migration.name(),
                    file=sys.stderr)
                migrate_app(migrations, 'current-1', verbosity=verbosity)
            for ext in ('py', 'pyc'):
                old_filename = "%s.%s" % (
                    os.path.join(migrations.migrations_dir(),
                                 last_migration.filename), ext)
                if os.path.isfile(old_filename):
                    os.unlink(old_filename)
            migrations.remove(last_migration)

        # See what filename is next in line. We assume they use numbers.
        new_filename = migrations.next_filename(name)

        # - is a special name which means 'print to stdout'
        if name == "-":
            print(file_contents)
        # Write the migration file if the name isn't -
        else:
            fp = open(os.path.join(migrations.migrations_dir(), new_filename),
                      "w")
            fp.write(file_contents)
            fp.close()
            verb = 'Updated' if update else 'Created'
            if empty:
                print(
                    "%s %s. You must now edit this migration and add the code for each direction." % (
                        verb, new_filename), file=sys.stderr)
            else:
                print(
                    "%s %s. You can now apply this migration with: ./manage.py migrate %s" % (
                        verb, new_filename, app), file=sys.stderr)
开发者ID:repodevs,项目名称:bluebottle,代码行数:101,代码来源:bb_schemamigration.py

示例15: handle

 def handle(self, *args, **options):
     
     
     _auto = options.get('auto', False)
     # Loop through all give apps 
     # Or fail as no apps are supplied.
     if len(args) <= 0:
         self.say("No apps supplied")
         exit(1)
         
     for a in args:
         try:
             module, app = self.app_label_to_app_module(a)
             
             #print "Objects", module, app
         except ImproperlyConfigured as (e):
             module, app = None, None
             self.say("App '%s' could not be found." % a)
         
         if app:
             me = self.migrations_exist(module)
             if me:
                 self.say("Auto migrations for %s" % a)
                 _auto = True
             else:
                 self.say("New migrations for %s" % a)
                 _auto = False
                 
             if _auto == True:
                 _initial = False
             else:
                 _initial = True
             from django.core import management
             
             options.update({'initial':_initial, 
                'auto':_auto})
             p = str(a)
             
             try:
                 management.call_command('schemamigration', p, **options)
             finally:
                 from south.migration import Migration, Migrations
                 # Migrate each app
                 
                 if a:
                     try:
                         
                         apps = [Migrations(a)]
                         _s = 's'
                         if len(apps) == 1: _s = ''
                         print "Migrating %s app%s in '%s' " % (len(apps), _s,  a)
                          
                         for app in apps:
                             result = migration.migrate_app(
                                 apps,
                                 target_name = None,
                                 fake = options.get('fake', False),
                                 db_dry_run = options.get('db_dry_run', False),
                                 verbosity = int(options.get('verbosity', 0)),
                                 interactive = options.get('interactive', True),
                                 load_initial_data = not options.get('no_initial_data', False),
                                 merge = options.get('merge', True),
                                 skip = False,
                                 database = options.get('database', DEFAULT_DB_ALIAS),
                                 delete_ghosts = options.get('delete_ghosts', False),
                                 ignore_ghosts = options.get('ignore_ghosts', False),
                             )
                         if result is False:
                             sys.exit(1) # Migration failed, so the command fails.
                     except NoMigrations:
                         print "The app '%s' does not appear to use migrations." % app
                         print "./manage.py migrate " + self.args
                         return
                 else:
                     apps = list(migration.all_migrations())
开发者ID:davidrae,项目名称:abacus-direct,代码行数:75,代码来源:easy_migrate.py


注:本文中的south.migration.migrate_app函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。