添加报表页面,更新用户管理和注册功能
This commit is contained in:
@@ -66,6 +66,9 @@ def migrate_database(conn, target_version: int) -> None:
|
||||
if current_version < 10:
|
||||
_migrate_to_v10(conn)
|
||||
current_version = 10
|
||||
if current_version < 11:
|
||||
_migrate_to_v11(conn)
|
||||
current_version = 11
|
||||
|
||||
if current_version != int(target_version):
|
||||
set_current_version(conn, int(target_version))
|
||||
@@ -450,3 +453,26 @@ def _migrate_to_v10(conn):
|
||||
|
||||
if changed:
|
||||
conn.commit()
|
||||
|
||||
|
||||
def _migrate_to_v11(conn):
|
||||
"""迁移到版本11 - 取消注册待审核:历史 pending 用户直接置为 approved"""
|
||||
cursor = conn.cursor()
|
||||
now_str = get_cst_now_str()
|
||||
|
||||
try:
|
||||
cursor.execute(
|
||||
"""
|
||||
UPDATE users
|
||||
SET status = 'approved',
|
||||
approved_at = COALESCE(NULLIF(approved_at, ''), ?)
|
||||
WHERE status = 'pending'
|
||||
""",
|
||||
(now_str,),
|
||||
)
|
||||
updated = cursor.rowcount
|
||||
conn.commit()
|
||||
if updated:
|
||||
print(f" ✓ 已将 {updated} 个 pending 用户迁移为 approved")
|
||||
except sqlite3.OperationalError as e:
|
||||
print(f" ⚠️ v11 迁移跳过: {e}")
|
||||
|
||||
Reference in New Issue
Block a user