前后端更新
This commit is contained in:
1 parent
a0c8721fbb
commit
24da604727
33 files changed
+1951
-580
No files matched your search
@@ -0,0 +1,46 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
# Add backend directory to path
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
# Force SQLite for local testing BEFORE importing app
|
||||
db_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'local_test.db')
|
||||
os.environ['DATABASE_URL'] = f'sqlite:///{db_path}'
|
||||
print(f"Setting DATABASE_URL to: {os.environ['DATABASE_URL']}")
|
||||
|
||||
from app import create_app, db
|
||||
from app.models import User, Agent
|
||||
|
||||
app = create_app('development')
|
||||
|
||||
with app.app_context():
|
||||
print(f"Creating database tables at {db_path}...")
|
||||
db.create_all()
|
||||
print("Tables created successfully.")
|
||||
|
||||
# Check if we need to seed data
|
||||
user = User.query.filter_by(username='admin').first()
|
||||
if user is None:
|
||||
print("Seeding initial user 'admin'...")
|
||||
user = User(username='admin', email='admin@example.com', role='admin')
|
||||
user.set_password('Hxit@54321')
|
||||
db.session.add(user)
|
||||
else:
|
||||
# Update password if user exists
|
||||
print("Updating admin password to 'Hxit@54321'...")
|
||||
user.set_password('Hxit@54321')
|
||||
|
||||
if Agent.query.first() is None:
|
||||
print("Seeding initial agent 'Demo Agent'...")
|
||||
agent = Agent(
|
||||
name='Demo Agent',
|
||||
description='A test agent for local verification',
|
||||
type='api',
|
||||
dify_api_key='test-key',
|
||||
is_active=True
|
||||
)
|
||||
db.session.add(agent)
|
||||
|
||||
db.session.commit()
|
||||
print("Database seeded successfully.")
|
||||
Reference in new issue
Block a user