mobile database migrate_message themes
This commit is contained in:
Binary file not shown.
35
migrate_message.py
Normal file
35
migrate_message.py
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
"""
|
||||||
|
数据库迁移脚本:为 message 表添加 mentions 字段
|
||||||
|
"""
|
||||||
|
import sqlite3
|
||||||
|
import os
|
||||||
|
|
||||||
|
db_path = 'instance/database.db'
|
||||||
|
|
||||||
|
if not os.path.exists(db_path):
|
||||||
|
print(f"错误:找不到数据库文件 {db_path}")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
conn = sqlite3.connect(db_path)
|
||||||
|
cursor = conn.cursor()
|
||||||
|
|
||||||
|
print("开始数据库迁移...\n")
|
||||||
|
|
||||||
|
# 检查 message 表
|
||||||
|
print("检查 message 表...")
|
||||||
|
cursor.execute("PRAGMA table_info(message)")
|
||||||
|
columns = [row[1] for row in cursor.fetchall()]
|
||||||
|
print(f"现有列: {columns}")
|
||||||
|
|
||||||
|
if 'mentions' not in columns:
|
||||||
|
print("添加 mentions 字段...")
|
||||||
|
cursor.execute("ALTER TABLE message ADD COLUMN mentions TEXT")
|
||||||
|
print("[OK] 已添加 mentions 字段")
|
||||||
|
else:
|
||||||
|
print("[OK] mentions 字段已存在")
|
||||||
|
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
print("\n[SUCCESS] 数据库迁移完成!")
|
||||||
|
print("现在可以正常使用聊天功能了。")
|
||||||
Reference in New Issue
Block a user