forked from mtusi2026/mtusi2026lab3
Исправить балансировку и миграции лабы 3
This commit is contained in:
@@ -20,7 +20,6 @@ async def init_pool(dsn: str) -> asyncpg.Pool:
|
||||
command_timeout=5,
|
||||
timeout=5,
|
||||
)
|
||||
await _run_migrations(_pool)
|
||||
return _pool
|
||||
|
||||
|
||||
@@ -51,6 +50,14 @@ async def _run_migrations(p: asyncpg.Pool) -> None:
|
||||
await conn.execute("SELECT pg_advisory_unlock($1)", MIGRATION_LOCK_KEY)
|
||||
|
||||
|
||||
async def run_migrations(dsn: str) -> None:
|
||||
p = await asyncpg.create_pool(dsn, min_size=1, max_size=2, command_timeout=5, timeout=5)
|
||||
try:
|
||||
await _run_migrations(p)
|
||||
finally:
|
||||
await p.close()
|
||||
|
||||
|
||||
async def _apply_migrations(conn: asyncpg.Connection) -> None:
|
||||
await conn.execute(
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user