执行环境:
221.182.45.100:8066(Mycat 2.0,MySQL 5.7.33 兼容)
执行时间:2026-09-26 23:06 ~ 23:17
目标逻辑库:charging_pile_other
| 脚本 | 结果 |
|---|---|
20260926_charge_authorization.sql |
无需执行:t_charge_authorization 表已存在,结构与最新脚本完全一致(含 partner_ids、uk_company_id、全部最新注释) |
20260926_charge_authorization_partner_ids.sql |
无需执行:partner_ids 列已存在,执行会报 Duplicate column name |
20260926_vin_menu_repair.sql(本次新建) |
已执行生效:补齐 VIN 码管理菜单(父菜单 / 列表 / 6 个按钮) |
20260926_vin_allocate_auth.sql |
已执行生效:额度分配按钮 menu_id=315,已授予管理员角色 |
charging_pile_other.sys_menu 中原无任何 VIN 相关菜单(path LIKE '%vinManagement%' 计数 = 0)。20260901_vin_management.sql 第 18 行起使用 SET @变量 := (SELECT ...),**Mycat 2.0 不支持用户变量**,导致该脚本菜单部分静默不生效(建表部分正常)。20260926_vin_allocate_auth.sql 首次执行**影响 0 行**(父菜单 /vinManagement/list 不存在,INSERT ... SELECT 无匹配行)。20260926_vin_menu_repair.sql(纯子查询、无用户变量、全部幂等)补齐菜单后重跑权限脚本,生效。OR/AND 优先级缺括号,重复执行报 Duplicate entry '1-307' for key 'sys_role_menu.PRIMARY',已修复(菜单范围整体加括号)。charging_pile_other.sys_menu 新增记录:
| menu_id | parent_id | 名称 | 类型 | perms |
|---|---|---|---|---|
| 307 | 0 | VIN码管理 | M | /vinManagement |
| 308 | 307 | VIN码管理 | C | /vinManagement/list |
| 309 | 308 | 新增 | F | /vinManagement/add |
| 310 | 308 | 编辑 | F | /vinManagement/edit |
| 311 | 308 | 删除 | F | /vinManagement/delete |
| 312 | 308 | 启停 | F | /vinManagement/status |
| 313 | 308 | 导入 | F | /vinManagement/import |
| 314 | 308 | 导出 | F | /vinManagement/export |
| 315 | 308 | 额度分配 | F | /vinManagement/allocate |
charging_pile_other.sys_role_menu:以上 9 条菜单均已授予 role_id = 1(管理员)。
其他确认项:
- t_charge_authorization:表存在、0 行数据(待后台配置)。
- t_vin_management(charging_pile_account):含 company_id / fleet_id / init_quota / app_user_id,20260924 额度脚本已生效。
- t_fleet、t_group_company(charging_pile_other):存在,字段齐备。
三个脚本各重复执行一次(mysql -e "source ..."):
20260926_vin_menu_repair.sql → EXIT=0,无错误20260926_vin_allocate_auth.sql → EXIT=0,无错误20260926_charge_authorization.sql → EXIT=0,无错误ruoyi-api-other + ruoyi-other(充电授权)、ruoyi-api-account + ruoyi-account(VIN 额度分配);前端部署最新产物。# 判断(只读)
mysql -h<host> -P8066 -uroot -p --default-character-set=utf8mb4 -e "SELECT COUNT(*) FROM information_schema.TABLES WHERE TABLE_SCHEMA='charging_pile_other' AND TABLE_NAME='t_charge_authorization'"
# 执行(Mycat 建议先复制为英文文件名,再逐脚本 source)
mysql -h<host> -P8066 -uroot -p --default-character-set=utf8mb4 -e "source <绝对路径>/20260926_vin_menu_repair.sql"
20260926_vin_menu_repair.sql → 20260926_vin_allocate_auth.sql(额度分配按钮依赖 VIN码管理列表菜单)。20260926_charge_authorization.sql 与 20260926_charge_authorization_partner_ids.sql 为二选一分支;表已存在时两者都无需执行。SET @变量 / PREPARE,统一使用子查询写法(本目录脚本已按此改造)。--default-character-set=utf8mb4;ALTER TABLE 属 DDL 不可回滚,生产执行前先备份。| 脚本 | 结果 |
|---|---|
20260926_balance_warning.sql(本次新建) |
已执行生效:charging_pile_other.t_company_balance_warning 创建成功 |
221.182.45.100:8066(Mycat 2.0,--default-character-set=utf8mb4;脚本先复制为英文临时名再 source,并校验 $LASTEXITCODE;临时文件与回查导出已清理)SHOW CREATE TABLE charging_pile_other.t_company_balance_warning 与脚本一致(company_warn_amount / sub_warn_amount decimal(12,2)、notify_object / notify_type tinyint、create_time / update_time / del_flag、唯一键 uk_company_id、中文列注释无乱码),表内 0 行(待后台配置)CREATE TABLE IF NOT EXISTS,重复执行无副作用(生产可随部署直接重跑)ruoyi-api-other + ruoyi-other 新版本与前端产物)| 脚本 | 结果 |
|---|---|
20260927_balance_warning_sub_amount_nullable.sql(本次新建) |
已执行生效:t_company_balance_warning.sub_warn_amount 由 NOT NULL 改为 NULL DEFAULT NULL |
t_group_company.account_mode = 1)公司下无子账户,"子账户预警线"不展示也不提交;原列 NOT NULL 会导致共享模式保存失败,故放宽为可空(存 NULL 表示不适用)。221.182.45.100:8066(Mycat 2.0,--default-character-set=utf8mb4;脚本复制为英文临时名后 source,逐条校验 $LASTEXITCODE;临时文件已清理)information_schema.COLUMNS 显示 sub_warn_amount IS_NULLABLE=YES、注释「子账户预警线(元,共享模式下不适用,存NULL)」;SHOW CREATE TABLE 与脚本一致(company_warn_amount 仍为 NOT NULL,唯一键 uk_company_id 保留),中文注释无乱码ALTER TABLE ... MODIFY COLUMN 语句本身可重复执行,本次连续执行两次均 EXIT=0、结构不变TCompanyBalanceWarning.subWarnAmount 已加 @TableField(updateStrategy = FieldStrategy.IGNORED),否则 MyBatis-Plus 默认策略会忽略 null,共享模式切换后旧子账户预警线不会被清空(该列可空是此策略生效的前提)