release: v2.1 - Prompt管理系统、页脚优化、图标修复
新增功能: - Prompt管理:后台新增Prompt模板管理功能 - 数据库迁移:新增prompt_templates表及默认数据 - 页脚优化:添加ICP备案号(浙ICP备2025154782号-1)和Microsoft Clarity统计 - 图标修复:详情页Material Icons替换为Emoji - 标签显示:修复编辑页标签名称无法显示的问题 技术改进: - 添加正则表达式提取标签名称 - 优化页脚样式和链接 - 完善增量部署文档 🚀 Generated with Claude Code Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
49
migrate_db.py
Normal file
49
migrate_db.py
Normal file
@@ -0,0 +1,49 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
数据库安全迁移脚本
|
||||
只创建缺失的表,不删除现有数据
|
||||
用于生产环境部署
|
||||
"""
|
||||
|
||||
import sys
|
||||
from app import create_app
|
||||
from models import db, Admin
|
||||
|
||||
def migrate_database():
|
||||
"""安全迁移数据库(不删除数据)"""
|
||||
app = create_app('production')
|
||||
|
||||
with app.app_context():
|
||||
print("正在检查数据库表...")
|
||||
|
||||
# 只创建不存在的表(不会删除数据)
|
||||
db.create_all()
|
||||
print("✓ 数据库表检查完成")
|
||||
|
||||
# 检查是否存在管理员
|
||||
admin_count = Admin.query.count()
|
||||
|
||||
if admin_count == 0:
|
||||
print("\n未找到管理员账号,正在创建默认管理员...")
|
||||
admin = Admin(
|
||||
username='admin',
|
||||
email='admin@example.com',
|
||||
is_active=True
|
||||
)
|
||||
admin.set_password('admin123')
|
||||
db.session.add(admin)
|
||||
db.session.commit()
|
||||
|
||||
print("✓ 默认管理员创建成功")
|
||||
print(" 用户名: admin")
|
||||
print(" 密码: admin123")
|
||||
print("\n⚠️ 请立即登录后台修改密码!")
|
||||
else:
|
||||
print(f"\n✓ 已存在 {admin_count} 个管理员账号")
|
||||
|
||||
print("\n" + "="*50)
|
||||
print("数据库迁移完成!")
|
||||
print("="*50)
|
||||
|
||||
if __name__ == '__main__':
|
||||
migrate_database()
|
||||
Reference in New Issue
Block a user