-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_db.py
More file actions
25 lines (20 loc) · 916 Bytes
/
setup_db.py
File metadata and controls
25 lines (20 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import os
from app import app
from database import db
from models import User, Document, ChatHistory
def setup_database():
print("🚀 Initializing Documind-AI Database Setup...")
with app.app_context():
try:
# This creates all tables defined in models.py
db.create_all()
print("✅ Database tables created successfully!")
# Optional: Check if a user exists, or print instructions
user_count = User.query.count()
print(f"📊 Current user count: {user_count}")
print("\nSetup complete! You can now run 'python app.py' to start the server.")
except Exception as e:
print(f"❌ Error during setup: {str(e)}")
print("\nMake sure your PostgreSQL server is running and the DATABASE_URL in .env is correct.")
if __name__ == "__main__":
setup_database()