fix logs
This commit is contained in:
parent
aaa02622e7
commit
d4d26d35a1
|
|
@ -21,19 +21,18 @@ async def lifespan(app: FastAPI):
|
||||||
# TEMPORARY: Clean up old deleted assets (remove this after first run)
|
# TEMPORARY: Clean up old deleted assets (remove this after first run)
|
||||||
from app.infra.database import AsyncSessionLocal
|
from app.infra.database import AsyncSessionLocal
|
||||||
from sqlalchemy import text
|
from sqlalchemy import text
|
||||||
import logging
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
async with AsyncSessionLocal() as session:
|
async with AsyncSessionLocal() as session:
|
||||||
# Check how many deleted assets exist
|
# Check how many deleted assets exist
|
||||||
result = await session.execute(text("SELECT COUNT(*) FROM assets WHERE status = 'deleted'"))
|
result = await session.execute(text("SELECT COUNT(*) FROM assets WHERE status = 'deleted'"))
|
||||||
count_before = result.scalar()
|
count_before = result.scalar()
|
||||||
logger.info(f"Found {count_before} assets with status='deleted'")
|
print(f"[MIGRATION] Found {count_before} assets with status='deleted'")
|
||||||
|
|
||||||
# Delete them
|
# Delete them
|
||||||
result = await session.execute(text("DELETE FROM assets WHERE status = 'deleted'"))
|
result = await session.execute(text("DELETE FROM assets WHERE status = 'deleted'"))
|
||||||
await session.commit()
|
await session.commit()
|
||||||
logger.info(f"Deleted {result.rowcount} assets with status='deleted'")
|
print(f"[MIGRATION] Deleted {result.rowcount} assets with status='deleted'")
|
||||||
|
print("[MIGRATION] Migration complete - you can now remove this code from main.py")
|
||||||
# END TEMPORARY
|
# END TEMPORARY
|
||||||
|
|
||||||
yield
|
yield
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue