Merge pull request 'bug Fix Login' (#2) from develop into main
Reviewed-on: #2
This commit is contained in:
commit
b789c1bd44
|
|
@ -43,7 +43,11 @@ AVATAR_COLORS = ['#1D9E75','#378ADD','#D85A30','#EF9F27','#7F77DD','#D4537E','#6
|
||||||
@app.on_event("startup")
|
@app.on_event("startup")
|
||||||
async def startup_event():
|
async def startup_event():
|
||||||
"""Run migrations and initialization on startup."""
|
"""Run migrations and initialization on startup."""
|
||||||
|
try:
|
||||||
init_db()
|
init_db()
|
||||||
|
except Exception as e:
|
||||||
|
print(f"⚠️ init_db() failed (non-fatal): {e}")
|
||||||
|
# Don't crash on startup - pipeline prompt can be created manually
|
||||||
|
|
||||||
def init_db():
|
def init_db():
|
||||||
"""Initialize database - Schema is loaded by startup.sh"""
|
"""Initialize database - Schema is loaded by startup.sh"""
|
||||||
|
|
@ -51,8 +55,21 @@ def init_db():
|
||||||
# This function kept for backwards compatibility
|
# This function kept for backwards compatibility
|
||||||
|
|
||||||
# Ensure "pipeline" master prompt exists
|
# Ensure "pipeline" master prompt exists
|
||||||
|
try:
|
||||||
with get_db() as conn:
|
with get_db() as conn:
|
||||||
cur = get_cursor(conn)
|
cur = get_cursor(conn)
|
||||||
|
# Check if table exists first
|
||||||
|
cur.execute("""
|
||||||
|
SELECT EXISTS (
|
||||||
|
SELECT FROM information_schema.tables
|
||||||
|
WHERE table_schema = 'public'
|
||||||
|
AND table_name = 'ai_prompts'
|
||||||
|
) as table_exists
|
||||||
|
""")
|
||||||
|
if not cur.fetchone()['table_exists']:
|
||||||
|
print("⚠️ ai_prompts table doesn't exist yet - skipping pipeline prompt creation")
|
||||||
|
return
|
||||||
|
|
||||||
cur.execute("SELECT COUNT(*) as count FROM ai_prompts WHERE slug='pipeline'")
|
cur.execute("SELECT COUNT(*) as count FROM ai_prompts WHERE slug='pipeline'")
|
||||||
if cur.fetchone()['count'] == 0:
|
if cur.fetchone()['count'] == 0:
|
||||||
cur.execute("""
|
cur.execute("""
|
||||||
|
|
@ -68,6 +85,9 @@ def init_db():
|
||||||
""")
|
""")
|
||||||
conn.commit()
|
conn.commit()
|
||||||
print("✓ Pipeline master prompt created")
|
print("✓ Pipeline master prompt created")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"⚠️ Could not create pipeline prompt: {e}")
|
||||||
|
# Don't fail startup - prompt can be created manually
|
||||||
|
|
||||||
# ── Helper: get profile_id from header ───────────────────────────────────────
|
# ── Helper: get profile_id from header ───────────────────────────────────────
|
||||||
def get_pid(x_profile_id: Optional[str] = Header(default=None)) -> str:
|
def get_pid(x_profile_id: Optional[str] = Header(default=None)) -> str:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user