This commit is contained in:
parent
7262ba4718
commit
5e0001b8c8
@ -37,6 +37,25 @@ load_dotenv()
|
||||
# Create database tables
|
||||
models.Base.metadata.create_all(bind=engine)
|
||||
|
||||
# ── Auto-migrate: add new columns if they don't exist yet ────────────────────
|
||||
def _run_startup_migrations():
|
||||
"""Idempotent column additions — safe to run on every deploy."""
|
||||
statements = [
|
||||
"ALTER TABLE events ADD COLUMN IF NOT EXISTS invitation_image_url TEXT;",
|
||||
"ALTER TABLE events ADD COLUMN IF NOT EXISTS guest_form_fields TEXT;",
|
||||
"ALTER TABLE guests_v2 ADD COLUMN IF NOT EXISTS companion_count INTEGER DEFAULT 0;",
|
||||
]
|
||||
from sqlalchemy import text
|
||||
with engine.connect() as conn:
|
||||
for stmt in statements:
|
||||
try:
|
||||
conn.execute(text(stmt))
|
||||
except Exception as e:
|
||||
print(f"[startup migration] warning: {e}")
|
||||
conn.commit()
|
||||
|
||||
_run_startup_migrations()
|
||||
|
||||
app = FastAPI(title="Multi-Event Invitation Management API")
|
||||
|
||||
# Ensure uploads directory exists and serve it as static files
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user