def test_get_app_name(self): self.assertEqual( "southtest", migration.get_app_name(self.create_fake_app("southtest.migrations")), ) self.assertEqual( "baz", migration.get_app_name(self.create_fake_app("foo.bar.baz.migrations")), )
def list_migrations(apps): from south.models import MigrationHistory apps = list(apps) names = [migration.get_app_name(app) for app in apps] applied_migrations = MigrationHistory.objects.filter(app_name__in=names) applied_migrations = ['%s.%s' % (mi.app_name,mi.migration) for mi in applied_migrations] print for app in apps: print migration.get_app_name(app) all_migrations = migration.get_migration_names(app) for migration_name in all_migrations: long_form = '%s.%s' % (migration.get_app_name(app),migration_name) if long_form in applied_migrations: print format_migration_list_item(migration_name) else: print format_migration_list_item(migration_name, applied=False) print