From a9751783b2b596f5bc54c6ec6b45a816db20a3e7 Mon Sep 17 00:00:00 2001 From: Xiaoxia AI Date: Sun, 21 Jun 2026 07:04:39 +0800 Subject: [PATCH] fix(deploy): parameterize alembic schema probe --- infra/docker/deploy-staging.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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