fix: preserve takeover and share token integrity
This commit is contained in:
@@ -38,8 +38,9 @@ def init_db():
|
||||
("authorizations", "takeover_enabled", "BOOLEAN DEFAULT 0"),
|
||||
("authorizations", "takeover_mode", "VARCHAR DEFAULT 'immediate'"),
|
||||
("authorizations", "takeover_delay_seconds", "INTEGER DEFAULT 30"),
|
||||
("avatars", "share_token", "VARCHAR DEFAULT ''"),
|
||||
("avatars", "share_token", "VARCHAR DEFAULT NULL"),
|
||||
)
|
||||
_normalize_optional_unique_values()
|
||||
|
||||
|
||||
def _try_add_columns(*cols):
|
||||
@@ -51,3 +52,8 @@ def _try_add_columns(*cols):
|
||||
except Exception:
|
||||
# 列已存在(或全新库由 create_all 建好)则忽略
|
||||
pass
|
||||
|
||||
|
||||
def _normalize_optional_unique_values():
|
||||
with engine.begin() as conn:
|
||||
conn.exec_driver_sql("UPDATE avatars SET share_token = NULL WHERE share_token = ''")
|
||||
|
||||
Reference in New Issue
Block a user