bug fixes for local deployment model
This commit is contained in:
+8
-2
@@ -106,7 +106,13 @@ async def lifespan(app: FastAPI):
|
||||
# Create tables on startup, then patch any missing columns
|
||||
async with engine.begin() as conn:
|
||||
await conn.run_sync(_cleanup_orphaned_sequences)
|
||||
await conn.run_sync(Base.metadata.create_all)
|
||||
try:
|
||||
await conn.run_sync(Base.metadata.create_all)
|
||||
except Exception as e:
|
||||
if "duplicate" in str(e).lower():
|
||||
print(f" → Tables already exist (partial creation from prior restart): {e}")
|
||||
else:
|
||||
raise
|
||||
await conn.run_sync(_migrate_add_missing_columns)
|
||||
|
||||
# Auto-seed if database is empty
|
||||
@@ -117,7 +123,7 @@ async def lifespan(app: FastAPI):
|
||||
print(" → Database is empty — running seed...")
|
||||
from seed import seed as run_seed
|
||||
await run_seed()
|
||||
return # Full seed already included station config
|
||||
print(" ✓ Full seed completed (skipping station config check)")
|
||||
|
||||
# Ensure station config exists (runs even if DB already had data)
|
||||
async with async_session() as session:
|
||||
|
||||
Reference in New Issue
Block a user