fix: seed app_settings.currency от AURUM_DEFAULT_CURRENCY на чистой установке

This commit is contained in:
ZProger
2026-09-04 03:03:29 +03:00
parent c0f446b3b3
commit 9c98f5df96
3 changed files with 63 additions and 7 deletions

View File

@@ -79,9 +79,15 @@ async def seed_default_account(session: AsyncSession) -> None:
async def seed_default_app_settings(session: AsyncSession) -> None:
"""Ensures the singleton app_settings row (id=1) exists — the migration
already inserts it, but this makes app boot self-healing if that row is
ever missing (e.g. a DB restored from a pre-currency-setting backup)."""
"""Ensures the singleton app_settings row (id=1) exists, seeded with
AURUM_DEFAULT_CURRENCY. The sole place that row gets created — the
9f3a2d7c5e11 migration only creates the table now, not the row itself
(an earlier version hardcoded the row to 'USD' at migration time, which
silently ignored AURUM_DEFAULT_CURRENCY on a fresh install since this
function's own get-or-create check would find the row already there).
Runs on every app boot (see main.py's lifespan), so it's also
self-healing if the row is ever missing (e.g. a DB restored from a
pre-currency-setting backup)."""
existing = await session.get(AppSettings, 1)
if existing is not None:
return