16 lines
583 B
Python
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."
|
|
)
|