Skip to content

Commit ebd46af

Browse files
committed
Fix NameError in main.py: Import SessionLocal and safe rollback
1 parent 1977122 commit ebd46af

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

backend/main.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,9 @@ def _fix_schema_constraints(db: Session):
308308
print(f"⚠️ [DB MIGRATION] Setup failed: {e}")
309309

310310
# --- 2. Seed Personas (Fresh Session) ---
311+
db = None
311312
try:
313+
from database import SessionLocal
312314
db = SessionLocal()
313315
print("🌱 [SEED] Verify Personas in DB...")
314316
# Import moved inside to avoid circular deps if any
@@ -350,9 +352,11 @@ def _fix_schema_constraints(db: Session):
350352
print("✅ [DB] Schema & Seeds synced.")
351353
except Exception as e:
352354
print(f"❌ [DB] Seed Error: {e}")
353-
db.rollback()
355+
if db:
356+
db.rollback()
354357
finally:
355-
db.close()
358+
if db:
359+
db.close()
356360

357361
# Background evaluator (best-effort)
358362
try:

0 commit comments

Comments
 (0)