fix migration

This commit is contained in:
2026-06-16 09:40:14 +03:00
parent 81c8117520
commit 9c09152bbf
2 changed files with 54 additions and 17 deletions
+8 -1
View File
@@ -29,12 +29,19 @@ def _add_column_if_missing(table: str, column: str, ddl: str) -> None:
def _ensure_schema_migrations_table() -> None:
from app.db.dialect import is_postgresql
applied_type = (
"TIMESTAMP DEFAULT CURRENT_TIMESTAMP"
if is_postgresql(engine)
else "DATETIME DEFAULT CURRENT_TIMESTAMP"
)
with engine.begin() as conn:
conn.execute(
text(
"CREATE TABLE IF NOT EXISTS _schema_migrations ("
"name TEXT PRIMARY KEY, "
"applied_at DATETIME DEFAULT CURRENT_TIMESTAMP)"
f"applied_at {applied_type})"
)
)