

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)
    pre_migrate.send(None, app=app_label, verbosity=verbosity, interactive=verbosity, db=database)
    if (not migrations):
        print(("? You have no migrations for the '%s' app. You might want some." % app_label))
        return
    Migrations.calculate_dependencies()
    applied_all = MigrationHistory.objects.filter(applied__isnull=False).order_by('applied').using(database)
    applied = applied_all.filter(app_name=app_label).using(database)
    south.db.db = south.db.dbs[database]
    Migrations.invalidate_all_modules()
    south.db.db.debug = (verbosity > 1)
    if (target_name == 'current-1'):
        if (applied.count() > 1):
            previous_migration = applied[(applied.count() - 2)]
            if verbosity:
                print(('previous_migration: %s (applied: %s)' % (previous_migration.migration, previous_migration.applied)))
            target_name = previous_migration.migration
        else:
            if verbosity:
                print('previous_migration: zero')
            target_name = 'zero'
    elif (target_name == 'current+1'):
        try:
            first_unapplied_migration = get_unapplied_migrations(migrations, applied).next()
            target_name = first_unapplied_migration.name()
        except StopIteration:
            target_name = None
    applied_all = check_migration_histories(applied_all, delete_ghosts, ignore_ghosts)
    target = migrations.guess_migration(target_name)
    if verbosity:
        if ((target_name not in ('zero', None)) and (target.name() != target_name)):
            print((' - Soft matched migration %s to %s.' % (target_name, target.name())))
        print(('Running migrations for %s:' % app_label))
    (direction, problems, workplan) = get_direction(target, applied_all, migrations, verbosity, interactive)
    if (problems and (not (merge or skip))):
        raise exceptions.InconsistentMigrationHistory(problems)
    migrator = get_migrator(merge, db_dry_run, fake, load_initial_data)
    if migrator:
        migrator.print_title(target)
        success = migrator.migrate_many(target, workplan, database)
        if success:
            post_migrate.send(None, app=app_label, verbosity=verbosity, interactive=verbosity, db=database)
    else:
        if verbosity:
            print('- Nothing to migrate.')
        if load_initial_data:
            migrator = LoadInitialDataMigrator(migrator=Forwards(verbosity=verbosity))
            migrator.load_initial_data(target, db=database)
        post_migrate.send(None, app=app_label, verbosity=verbosity, interactive=verbosity, db=database)

dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/South-1.0.2/south/migration/__init__.py migrate_app/VarMisuse@459/702 `direction`->`merge`