Files
xiaoxia-saas/packages/adapters/sqlalchemy_impl/schema_guard.py
T
Xiaoxia AI 309906cb53
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 13s
Deploy / Deploy Staging (push) Successful in 1m56s
Deploy / Deploy Production (push) Has been skipped
fix(schema): forbid auto create schema in deployed envs
2026-06-21 07:36:46 +08:00

16 lines
583 B
Python

from __future__ import annotations
BLOCKED_AUTO_CREATE_ENVIRONMENTS = {"staging", "production"}
def normalize_environment(environment: str | None) -> str:
return (environment or "development").strip().lower()
def assert_auto_create_schema_allowed(environment: str | None, enabled: bool) -> None:
normalized = normalize_environment(environment)
if enabled and normalized in BLOCKED_AUTO_CREATE_ENVIRONMENTS:
raise RuntimeError(
"AUTO_CREATE_SCHEMA is forbidden in staging/production. " "Run Alembic migrations before starting services."
)