add migration script

codex/dev
mula.liu 2026-04-03 15:00:06 +08:00
parent 498bd97f99
commit df61cd870d
2 changed files with 1369 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,129 @@
# iMeeting `imeeting_qy` 数据库升级报告
## 1. 升级目标
- 源旧库:`imeeting_qy`
- 对标最新结构库:`imeeting`
- 升级日期:`2026-04-03`
- 执行方式:先在临时测试库 `imeeting_qy_upgrade_test` 演练,再正式执行到 `imeeting_qy`
## 2. 备份信息
- 正式升级前已创建完整备份库:`imeeting_qy_backup_20260403_004354`
- 备份方式:同服务器整库复制全部 `BASE TABLE`
## 3. 本次执行内容
本次升级使用迁移脚本:
- `backend/sql/migrations/upgrade_imeeting_qy_to_latest.sql`
核心动作如下:
1. 将旧系统表标准化为 `sys_*` 体系:
- `users -> sys_users`
- `roles -> sys_roles`
- `menus -> sys_menus`
- `role_menu_permissions -> sys_role_menu_permissions`
- `dict_data -> sys_dict_data`
2. 重建兼容视图:
- `users`
- `roles`
- `menus`
- `role_menu_permissions`
- `dict_data`
- `system_parameters`
3. 对齐旧系统表字段与索引:
- `sys_users` 补齐 `idx_role_id`
- `sys_roles` 补齐 `uk_role_name`
- `sys_menus` 补齐 `menu_level/tree_path/is_visible` 及相关索引
- `sys_role_menu_permissions` 补齐 `granted_by/granted_at` 及相关索引
- `prompts` 补齐 `is_system` 字段及组合索引
- `terminals.current_user_id` 字段注释对齐到最新结构
4. 新增并初始化最新配置表:
- `sys_system_parameters`
- `ai_model_configs`
- `llm_model_config`
- `audio_model_config`
- `hot_word_group`
- `hot_word_item`
- `prompt_config`
- `sys_user_mcp`
5. 迁移旧配置数据:
- 从 `sys_dict_data(dict_type='system_config')` 迁移系统参数到 `sys_system_parameters`
- 迁移 LLM / ASR / 声纹配置到 `ai_model_configs`
- 拆分生成 `llm_model_config`、`audio_model_config`
- 从旧 `hot_words` 迁移到 `hot_word_group` / `hot_word_item`
6. 重建最新菜单树与角色授权模型:
- 新增 `dashboard`、`desktop`、`meeting_manage`、`system_management` 等最新菜单结构
- 规范平台管理、系统管理、会议管理三套菜单层级
- 管理员角色授予全部启用菜单
- 普通用户保留 `desktop/meeting_manage/meeting_center/prompt_config`
## 4. 升级结果
升级后关键表数据如下:
| 表名 | 行数 |
|---|---:|
| `sys_users` | 44 |
| `sys_roles` | 2 |
| `sys_menus` | 19 |
| `sys_role_menu_permissions` | 22 |
| `sys_system_parameters` | 4 |
| `ai_model_configs` | 3 |
| `llm_model_config` | 1 |
| `audio_model_config` | 2 |
| `hot_word_group` | 1 |
| `hot_word_item` | 20 |
| `prompt_config` | 0 |
| `sys_user_mcp` | 0 |
迁移后的系统参数:
| 参数键 | 参数值 |
|---|---|
| `asr_vocabulary_id` | `vocab-imeeting-734e93f5bd8a4f3bb665dd526d584516` |
| `default_reset_password` | `123456` |
| `max_audio_size` | `500` |
| `timeline_pagesize` | `20` |
迁移后的模型配置:
- `llm_model_config`1 条默认模型,`model_code=llm_model`
- `audio_model_config`2 条配置
- `audio_model` / `asr`
- `voiceprint_model` / `voiceprint`
迁移后的热词配置:
- `hot_word_group`1 个默认热词组
- `hot_word_item`20 条热词条目
## 5. 角色菜单结果
- 平台管理员:
- `dashboard, hot_word_management, user_management, meeting_center, desktop, meeting_manage, model_management, permission_management, prompt_config, prompt_management, platform_admin, dict_management, system_management, client_management, external_app_management, terminal_management, parameter_management, permission_menu_tree`
- 普通用户:
- `meeting_center, desktop, meeting_manage, prompt_config`
## 6. 结构校验结论
`imeeting_qy``imeeting` 进行了 `information_schema.tables` + `information_schema.columns` 级别的最终校验,结果如下:
- 缺失表:`0`
- 多余表:`0`
- 表类型差异:`0`
- 字段差异:`0`
结论:
- `imeeting_qy` 已完成升级
- 当前库结构已与 `imeeting` 对齐
- 本次升级为“结构对齐 + 必要配置数据迁移”,未删除旧业务数据