forked from mtusi2026/mtusi2026lab3
реализация 3 лабы
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user