def reapply(args, config): backend = get_backend(args, config) with backend.lock(): migrations = get_migrations(args, backend) backend.rollback_migrations(migrations, args.force) migrations = backend.to_apply(migrations) backend.apply_migrations(migrations, args.force)
def show_migrations(args, config): backend = get_backend(args, config) with backend.lock(): migrations = get_migrations(args, backend) print(tabulate( [(m.id, '\033[92m Yes \033[0m' if m.applied else '\033[91m No \033[0m') for m in migrations], headers=['Migration', 'Applied']) )
def break_lock(args, config): backend = get_backend(args, config) backend.break_lock()
def unmark(args, config): backend = get_backend(args, config) with backend.lock(): migrations = get_migrations(args, backend) backend.unmark_migrations(migrations)
def rollback(args, config): backend = get_backend(args, config) with backend.lock(): migrations = get_migrations(args, backend) backend.rollback_migrations(migrations, args.force)
def apply(args, config): backend = get_backend(args, config) with backend.lock(): migrations = get_migrations(args, backend) backend.apply_migrations(migrations, args.force)