Skip to content

Commit 5b4e586

Browse files
author
Uttam Singh
committed
Add /create-db route to initialize database on Render
1 parent a5ba603 commit 5b4e586

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

backend/app/main.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,15 @@
3434
# at the bottom: include users router
3535
from app.routers import users
3636
app.include_router(users.router, prefix="/users", tags=["Users"])
37+
# --- TEMPORARY: Create Database Tables on Render ---
38+
from app.models.user import User
39+
from app.database import Base, engine
40+
41+
@app.get("/create-db")
42+
def create_database():
43+
try:
44+
Base.metadata.create_all(bind=engine)
45+
return {"ok": True, "message": "Database tables created successfully"}
46+
except Exception as e:
47+
return {"ok": False, "error": str(e)}
48+

0 commit comments

Comments
 (0)