24 lines
586 B
Python
24 lines
586 B
Python
|
|
import os
|
||
|
|
import sys
|
||
|
|
|
||
|
|
# 添加项目根目录到Python路径
|
||
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||
|
|
|
||
|
|
# 设置数据库URL为SQLite
|
||
|
|
os.environ['DATABASE_URL'] = 'sqlite:///kamaxitong.db'
|
||
|
|
|
||
|
|
from app import create_app, db
|
||
|
|
from flask_migrate import upgrade
|
||
|
|
|
||
|
|
# 创建应用实例
|
||
|
|
app = create_app()
|
||
|
|
|
||
|
|
with app.app_context():
|
||
|
|
print("Running database migrations...")
|
||
|
|
try:
|
||
|
|
upgrade()
|
||
|
|
print("Migrations completed successfully!")
|
||
|
|
except Exception as e:
|
||
|
|
print(f"Migration failed: {e}")
|
||
|
|
import traceback
|
||
|
|
traceback.print_exc()
|