Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions backend/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,23 @@
async def lifespan(app: FastAPI):
import os

from sqlalchemy import text

from app.core.database import Base, engine

os.makedirs("data", exist_ok=True)
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.create_all)
# Lightweight column migrations for existing tables
for table, column, col_type in [
("scenes", "scene_card_json", "TEXT"),
]:
try:
await conn.execute(
text(f"ALTER TABLE {table} ADD COLUMN {column} {col_type}")
)
except Exception:
pass # Column already exists
yield


Expand Down