def main(ctx, user): user and drop_privileges(user) if db_migratable(): log.error("Database schema version mismatch. Expected: '%s'. " "Optionally make a backup and then apply automatic database " "migration by using: 'vmcloak migrate'" % SCHEMA_VERSION) if ctx.invoked_subcommand != "migrate": exit(1)
def main(ctx, user): user and drop_privileges(user) if db_migratable(): log.error( "Database schema version mismatch. Expected: '%s'. " "Optionally make a backup and then apply automatic database " "migration by using: 'vmcloak migrate'" % SCHEMA_VERSION ) if ctx.invoked_subcommand != "migrate": exit(1)
def migrate(revision): log.setLevel(logging.INFO) if not db_migratable(): log.info("Database schema is already at the latest version") exit(0) try: subprocess.check_call( ["alembic", "upgrade", "%s" % revision], cwd=os.path.join(VMCLOAK_ROOT, "data", "db_migration")) except subprocess.CalledProcessError as e: log.exception("Database migration failed: %s", e) exit(1) log.info("Database migration successful!")
def migrate(revision): log.setLevel(logging.INFO) if not db_migratable(): log.info("Database schema is already at the latest version") exit(0) try: subprocess.check_call( ["alembic", "upgrade", "%s" % revision], cwd=os.path.join(VMCLOAK_ROOT, "data", "db_migration") ) except subprocess.CalledProcessError as e: log.exception("Database migration failed: %s", e) exit(1) log.info("Database migration successful!")