Files
plm-lottery/app/rounds/config.py
T

18 lines
687 B
Python
Raw Normal View History

from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from app.db.models import RoundConfig
async def get_round_config(session: AsyncSession) -> RoundConfig:
"""Single-row operational config, lazily created on first use with the
column defaults declared on RoundConfig itself (app/db/models.py) — no env
var involved. fee_address starts empty until an operator sets it via the
admin panel/API — payouts must refuse to run until it's set."""
config = await session.scalar(select(RoundConfig))
if config is None:
config = RoundConfig(fee_address="")
session.add(config)
await session.flush()
return config