This commit is contained in:
itqop 2025-12-30 23:16:07 +03:00
parent 8e79c4731b
commit aaa02622e7
1 changed files with 11 additions and 1 deletions

View File

@ -21,9 +21,19 @@ async def lifespan(app: FastAPI):
# TEMPORARY: Clean up old deleted assets (remove this after first run)
from app.infra.database import AsyncSessionLocal
from sqlalchemy import text
import logging
logger = logging.getLogger(__name__)
async with AsyncSessionLocal() as session:
await session.execute(text("DELETE FROM assets WHERE status = 'deleted'"))
# Check how many deleted assets exist
result = await session.execute(text("SELECT COUNT(*) FROM assets WHERE status = 'deleted'"))
count_before = result.scalar()
logger.info(f"Found {count_before} assets with status='deleted'")
# Delete them
result = await session.execute(text("DELETE FROM assets WHERE status = 'deleted'"))
await session.commit()
logger.info(f"Deleted {result.rowcount} assets with status='deleted'")
# END TEMPORARY
yield