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

@@ -25,10 +25,15 @@ def upgrade() -> None:
sa.Column('currency', sa.String(length=3), nullable=False, server_default='USD'),
sa.PrimaryKeyConstraint('id'),
)
# Singleton row (id=1) — app boot's seed_default_app_settings() also
# get-or-creates it, but seeding it here means it exists immediately
# after migrating, even before the app has started once.
op.execute("INSERT INTO app_settings (id, currency) VALUES (1, 'USD')")
# Singleton row (id=1) — deliberately NOT seeded here anymore (a prior
# version of this migration hardcoded `INSERT ... VALUES (1, 'USD')`,
# which silently ignored AURUM_DEFAULT_CURRENCY on a fresh install: the
# row already existed by the time app boot's seed_default_app_settings()
# ran its own get-or-create check, so a non-USD default never took).
# seed_default_app_settings() runs on every app boot (see main.py's
# lifespan) and already reads get_settings().default_currency correctly
# — leaving row creation to it entirely is both simpler and correct for
# every configured currency, not just USD.
def downgrade() -> None: