Реализовать лабораторную 3 на оценку 5 (трек 1)

This commit is contained in:
Чиняева
2026-11-07 00:57:10 +03:00
parent 0ab3a341aa
commit 2c4f0a5a61
96 changed files with 7784 additions and 45 deletions
+33
View File
@@ -0,0 +1,33 @@
"""One-shot migration entry point used by Compose.
Run after PostgreSQL is healthy and before API replicas start:
python -m app.migrate
"""
from __future__ import annotations
import logging
import sys
from . import db
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(name)s %(message)s")
def main() -> int:
try:
db.pool().open(wait=True, timeout=60)
db.apply_migrations()
if not db.schema_is_current():
raise RuntimeError("schema verification failed after migration")
except Exception as exc:
logging.getLogger("messenger.migrate").error("migration failed: %s", type(exc).__name__)
return 1
finally:
db.close_pool()
logging.getLogger("messenger.migrate").info("migrations applied and verified")
return 0
if __name__ == "__main__":
sys.exit(main())