Исправить балансировку и миграции лабы 3

This commit is contained in:
2026-11-18 17:44:53 +03:00
parent 2f1cf3afac
commit e51dc20fce
6 changed files with 106 additions and 6 deletions
+24
View File
@@ -0,0 +1,24 @@
"""Run database migrations as a dedicated deployment step."""
import asyncio
import os
from pathlib import Path
from . import db
def read_secret(name: str, fallback: str) -> str:
path = os.environ.get(name)
if path:
return Path(path).read_text(encoding="utf-8").strip()
value = os.environ.get(fallback)
if not value:
raise RuntimeError(f"{name} or {fallback} is required")
return value
async def main() -> None:
await db.run_migrations(read_secret("DATABASE_URL_FILE", "DATABASE_URL"))
if __name__ == "__main__":
asyncio.run(main())