Files

28 lines
879 B
Python

from fastapi import APIRouter
from app.config import settings
from app.database import get_session
from app.models import Event, StationConfig, Show, ShowSchedule
router = APIRouter()
@router.post("/reset")
async def reset_database():
"""Truncate all tables and re-seed. Dev-only — disabled in production."""
if settings.ENV == "production":
return {"error": "Admin reset is disabled in production"}
from app.database import async_session
from seed import seed as run_seed
async with async_session() as session:
await session.execute(ShowSchedule.__table__.delete())
await session.execute(Show.__table__.delete())
await session.execute(Event.__table__.delete())
await session.execute(StationConfig.__table__.delete())
await session.commit()
await run_seed()
return {"status": "reset complete"}