diff --git a/infra/docker/deploy-staging.sh b/infra/docker/deploy-staging.sh index 52172cd71..f45d22876 100644 --- a/infra/docker/deploy-staging.sh +++ b/infra/docker/deploy-staging.sh @@ -46,8 +46,17 @@ from sqlalchemy import create_engine, text url = os.environ["DATABASE_URL"] engine = create_engine(url) with engine.begin() as conn: - has_version = conn.execute(text("SELECT to_regclass($$public.alembic_version$$)")).scalar() is not None - has_tables = conn.execute(text("SELECT COUNT(*) FROM pg_tables WHERE schemaname = 'public' AND tablename != 'alembic_version'")).scalar() + has_version = conn.execute( + text("SELECT to_regclass(:table_name)"), + {"table_name": "public.alembic_version"}, + ).scalar() is not None + has_tables = conn.execute( + text( + "SELECT COUNT(*) FROM pg_tables " + "WHERE schemaname = :schema_name AND tablename != :version_table" + ), + {"schema_name": "public", "version_table": "alembic_version"}, + ).scalar() if has_tables and not has_version: raise SystemExit(42) PY