feat: add admin social login bindings

This commit is contained in:
237899745
2026-05-27 21:24:48 +08:00
parent 5dbe666420
commit 89cb98233f
39 changed files with 904 additions and 123 deletions

View File

@@ -77,6 +77,7 @@ def _get_migration_steps():
(20, _migrate_to_v20),
(21, _migrate_to_v21),
(22, _migrate_to_v22),
(23, _migrate_to_v23),
]
@@ -1002,3 +1003,33 @@ def _migrate_to_v22(conn):
cursor.execute("CREATE INDEX IF NOT EXISTS idx_social_pending_binds_expires ON social_pending_binds(expires_at)")
conn.commit()
def _migrate_to_v23(conn):
"""迁移到版本23 - 管理员聚合登录绑定。"""
cursor = conn.cursor()
cursor.execute(
"""
CREATE TABLE IF NOT EXISTS admin_social_login_bindings (
id INTEGER PRIMARY KEY AUTOINCREMENT,
admin_id INTEGER NOT NULL,
provider TEXT NOT NULL,
social_uid TEXT NOT NULL,
nickname TEXT DEFAULT '',
avatar_url TEXT DEFAULT '',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
last_login_at TIMESTAMP,
UNIQUE (provider, social_uid),
UNIQUE (admin_id, provider),
FOREIGN KEY (admin_id) REFERENCES admins (id) ON DELETE CASCADE
)
"""
)
cursor.execute("CREATE INDEX IF NOT EXISTS idx_admin_social_login_bindings_admin ON admin_social_login_bindings(admin_id)")
cursor.execute(
"CREATE INDEX IF NOT EXISTS idx_admin_social_login_bindings_provider_uid ON admin_social_login_bindings(provider, social_uid)"
)
conn.commit()