working dev environment
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,26 @@
|
||||
from fastapi import APIRouter
|
||||
|
||||
from app.config import settings
|
||||
from app.database import get_session
|
||||
from app.models import DonationTier, Event, Program
|
||||
|
||||
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(Program.__table__.delete())
|
||||
await session.execute(Event.__table__.delete())
|
||||
await session.execute(DonationTier.__table__.delete())
|
||||
await session.commit()
|
||||
|
||||
await run_seed()
|
||||
return {"status": "reset complete"}
|
||||
Reference in New Issue
Block a user