Files
x-server-mobile/backend/database/migrations/012_cleanup_redundant_tables.sql
T
root 0489da5e40 refactor: 重构多飞书应用绑定架构和数据库清理
- 新增 user_feishu_apps 表支持用户绑定多个飞书应用
- users 表添加唯一约束(公司内邮箱/手机唯一)
- 迁移现有飞书数据到 user_feishu_apps 表
- 清理冗余表(users_bak, user_feishu_binding)
- 废弃 users 表中的 feishu_user_id/feishu_open_id/tenant_key 字段
- 更新 FeishuNotificationService 使用新的数据获取方式
- User 模型新增 getFeishuUserId() 等便捷方法

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 16:27:33 +08:00

32 lines
794 B
SQL

-- X-Server 清理冗余表
-- 执行前请确认已备份数据库
USE xserver;
-- =====================================
-- 1. 删除 users_bak 表(用户表旧版备份)
-- =====================================
DROP TABLE IF EXISTS users_bak;
-- =====================================
-- 2. 删除 user_feishu_binding 表(已被 user_feishu_apps 替代)
-- =====================================
DROP TABLE IF EXISTS user_feishu_binding;
-- =====================================
-- 验证结果
-- =====================================
SELECT "=== 当前表列表 ===" as "";
SHOW TABLES;
SELECT "=== user_feishu_apps 统计 ===" as "";
SELECT
company_id,
COUNT(DISTINCT user_id) as users_count,
COUNT(*) as bindings_count
FROM user_feishu_apps
GROUP BY company_id;