Update app/main.py
Browse files- app/main.py +10 -5
app/main.py
CHANGED
|
@@ -5,7 +5,10 @@ from app.core.database import engine, Base
|
|
| 5 |
from datetime import datetime
|
| 6 |
import os
|
| 7 |
import logging
|
|
|
|
|
|
|
| 8 |
from app.models import Repository, Conversation, Message, CodeFile
|
|
|
|
| 9 |
# Configure logging
|
| 10 |
logging.basicConfig(level=logging.INFO)
|
| 11 |
logger = logging.getLogger(__name__)
|
|
@@ -32,15 +35,17 @@ app.add_middleware(
|
|
| 32 |
allow_headers=["*"],
|
| 33 |
)
|
| 34 |
|
| 35 |
-
#
|
| 36 |
@app.on_event("startup")
|
| 37 |
async def startup_event():
|
| 38 |
-
"""
|
| 39 |
try:
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
| 42 |
except Exception as e:
|
| 43 |
-
logger.error(f"❌ Error
|
| 44 |
|
| 45 |
# Health check endpoint
|
| 46 |
@app.get("/health")
|
|
|
|
| 5 |
from datetime import datetime
|
| 6 |
import os
|
| 7 |
import logging
|
| 8 |
+
|
| 9 |
+
# Import all models so SQLAlchemy registers them before creating tables
|
| 10 |
from app.models import Repository, Conversation, Message, CodeFile
|
| 11 |
+
|
| 12 |
# Configure logging
|
| 13 |
logging.basicConfig(level=logging.INFO)
|
| 14 |
logger = logging.getLogger(__name__)
|
|
|
|
| 35 |
allow_headers=["*"],
|
| 36 |
)
|
| 37 |
|
| 38 |
+
# Load models on startup (but don't create tables - managed via Neon console)
|
| 39 |
@app.on_event("startup")
|
| 40 |
async def startup_event():
|
| 41 |
+
"""Load models so SQLAlchemy relationships work"""
|
| 42 |
try:
|
| 43 |
+
# Models are already imported at top of file
|
| 44 |
+
# This just ensures SQLAlchemy registry is ready
|
| 45 |
+
logger.info("🗄️ Database models loaded successfully")
|
| 46 |
+
logger.info("💡 Note: Tables are managed via Neon console, not auto-created")
|
| 47 |
except Exception as e:
|
| 48 |
+
logger.error(f"❌ Error loading models: {e}")
|
| 49 |
|
| 50 |
# Health check endpoint
|
| 51 |
@app.get("/health")
|