Update UI and migrations, fix dockerfile

This commit is contained in:
Your Name
2026-07-18 21:29:05 +05:00
parent 580c75cbf6
commit 26ef145ccf
95 changed files with 9541 additions and 111 deletions
+28
View File
@@ -0,0 +1,28 @@
import asyncio
import os
from pathlib import Path
import asyncpg
async def main() -> None:
root = Path(__file__).resolve().parents[1]
conn = await asyncpg.connect(os.environ["DATABASE_URL"])
try:
await conn.execute(
"CREATE TABLE IF NOT EXISTS schema_migrations (version TEXT PRIMARY KEY, applied_at TIMESTAMPTZ NOT NULL DEFAULT NOW())"
)
for path in sorted((root / "db" / "migrations").glob("*.sql")):
exists = await conn.fetchval("SELECT 1 FROM schema_migrations WHERE version=$1", path.name)
if exists:
continue
async with conn.transaction():
await conn.execute(path.read_text(encoding="utf-8"))
await conn.execute("INSERT INTO schema_migrations(version) VALUES($1)", path.name)
print(f"applied {path.name}")
finally:
await conn.close()
if __name__ == "__main__":
asyncio.run(main())