реализация 3 лабы

This commit is contained in:
Ванек
2026-10-29 14:51:19 +03:00
parent 74aa224251
commit 64ea89d040
28 changed files with 2411 additions and 243 deletions
+9
View File
@@ -8,6 +8,15 @@ from src import db
DIRECTORY = Path(__file__).resolve().parents[1] / "migrations"
def check():
"""API только проверяет схему; DDL выполняет отдельный migrate-service."""
with db.connection() as conn:
for path in sorted(DIRECTORY.glob("*.sql")):
row = conn.execute("SELECT checksum FROM schema_migrations WHERE version=%s", (path.name,)).fetchone()
if row is None or row["checksum"] != hashlib.sha256(path.read_bytes()).hexdigest():
raise RuntimeError("Сначала выполните миграции: " + path.name)
def apply():
applied = []
with db.connection() as conn: