fix(aihr): harden legacy schema migrations
This commit is contained in:
@@ -1,5 +1,18 @@
|
|||||||
-- AIHR 组织快照入职日期迁移(MySQL 8.x)
|
-- AIHR 组织快照入职日期迁移(MySQL 8.x)
|
||||||
-- 仅补齐结构,不写入业务数据;可重复执行。
|
-- 仅补齐结构,不写入业务数据;可重复执行。
|
||||||
|
SET @aihr_org_snapshot_table_exists := (
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM information_schema.TABLES
|
||||||
|
WHERE TABLE_SCHEMA = DATABASE()
|
||||||
|
AND TABLE_NAME = 'aihr_org_snapshot'
|
||||||
|
);
|
||||||
|
SET @aihr_employment_status_exists := (
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM information_schema.COLUMNS
|
||||||
|
WHERE TABLE_SCHEMA = DATABASE()
|
||||||
|
AND TABLE_NAME = 'aihr_org_snapshot'
|
||||||
|
AND COLUMN_NAME = 'employment_status'
|
||||||
|
);
|
||||||
SET @aihr_hire_date_exists := (
|
SET @aihr_hire_date_exists := (
|
||||||
SELECT COUNT(*)
|
SELECT COUNT(*)
|
||||||
FROM information_schema.COLUMNS
|
FROM information_schema.COLUMNS
|
||||||
@@ -8,8 +21,12 @@ SET @aihr_hire_date_exists := (
|
|||||||
AND COLUMN_NAME = 'hire_date'
|
AND COLUMN_NAME = 'hire_date'
|
||||||
);
|
);
|
||||||
SET @aihr_hire_date_ddl := IF(
|
SET @aihr_hire_date_ddl := IF(
|
||||||
@aihr_hire_date_exists = 0,
|
@aihr_org_snapshot_table_exists = 1 AND @aihr_hire_date_exists = 0,
|
||||||
'ALTER TABLE aihr_org_snapshot ADD COLUMN `hire_date` date DEFAULT NULL COMMENT ''入职日期(用于新员工三个月资格判断)'' AFTER `employment_status`',
|
IF(
|
||||||
|
@aihr_employment_status_exists = 1,
|
||||||
|
'ALTER TABLE aihr_org_snapshot ADD COLUMN `hire_date` date DEFAULT NULL COMMENT ''入职日期(用于新员工三个月资格判断)'' AFTER `employment_status`',
|
||||||
|
'ALTER TABLE aihr_org_snapshot ADD COLUMN `hire_date` date DEFAULT NULL COMMENT ''入职日期(用于新员工三个月资格判断)'''
|
||||||
|
),
|
||||||
'SELECT 1'
|
'SELECT 1'
|
||||||
);
|
);
|
||||||
PREPARE aihr_hire_date_stmt FROM @aihr_hire_date_ddl;
|
PREPARE aihr_hire_date_stmt FROM @aihr_hire_date_ddl;
|
||||||
|
|||||||
@@ -7,6 +7,22 @@ SET @aihr_sop_review_table_exists := (
|
|||||||
WHERE TABLE_SCHEMA = DATABASE()
|
WHERE TABLE_SCHEMA = DATABASE()
|
||||||
AND TABLE_NAME = 'aihr_sop_answer_review'
|
AND TABLE_NAME = 'aihr_sop_answer_review'
|
||||||
);
|
);
|
||||||
|
SET @aihr_sop_source_exists := (
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM information_schema.COLUMNS
|
||||||
|
WHERE TABLE_SCHEMA = DATABASE()
|
||||||
|
AND TABLE_NAME = 'aihr_sop_answer_review'
|
||||||
|
AND COLUMN_NAME = 'source'
|
||||||
|
);
|
||||||
|
SET @aihr_sop_source_ddl := IF(
|
||||||
|
@aihr_sop_review_table_exists = 1 AND @aihr_sop_source_exists = 0,
|
||||||
|
'ALTER TABLE aihr_sop_answer_review ADD COLUMN `source` varchar(50) DEFAULT ''knowledge_search'' COMMENT ''来源''',
|
||||||
|
'SELECT 1'
|
||||||
|
);
|
||||||
|
PREPARE aihr_sop_source_stmt FROM @aihr_sop_source_ddl;
|
||||||
|
EXECUTE aihr_sop_source_stmt;
|
||||||
|
DEALLOCATE PREPARE aihr_sop_source_stmt;
|
||||||
|
|
||||||
SET @aihr_sop_requester_exists := (
|
SET @aihr_sop_requester_exists := (
|
||||||
SELECT COUNT(*)
|
SELECT COUNT(*)
|
||||||
FROM information_schema.COLUMNS
|
FROM information_schema.COLUMNS
|
||||||
@@ -16,7 +32,7 @@ SET @aihr_sop_requester_exists := (
|
|||||||
);
|
);
|
||||||
SET @aihr_sop_requester_ddl := IF(
|
SET @aihr_sop_requester_ddl := IF(
|
||||||
@aihr_sop_review_table_exists = 1 AND @aihr_sop_requester_exists = 0,
|
@aihr_sop_review_table_exists = 1 AND @aihr_sop_requester_exists = 0,
|
||||||
'ALTER TABLE aihr_sop_answer_review ADD COLUMN `requester_ext_party_id` varchar(100) DEFAULT NULL COMMENT ''提问员工外部主体ID'' AFTER `source`',
|
'ALTER TABLE aihr_sop_answer_review ADD COLUMN `requester_ext_party_id` varchar(100) DEFAULT NULL COMMENT ''提问员工外部主体ID''',
|
||||||
'SELECT 1'
|
'SELECT 1'
|
||||||
);
|
);
|
||||||
PREPARE aihr_sop_requester_stmt FROM @aihr_sop_requester_ddl;
|
PREPARE aihr_sop_requester_stmt FROM @aihr_sop_requester_ddl;
|
||||||
|
|||||||
@@ -306,3 +306,5 @@
|
|||||||
- 2026-07-14 BRD 验收脚本可执行性修复:`scripts/tests/demo-check-pilot-gates.test.sh` 原文件权限为 `100644`,按其 shebang 直接执行会 `permission denied`;现改为 `100755`。直接执行通过(含临时测试库行为校验),`scripts/tests/pilot-export-contract.test.mjs` 通过 `5/5`;未修改业务数据。
|
- 2026-07-14 BRD 验收脚本可执行性修复:`scripts/tests/demo-check-pilot-gates.test.sh` 原文件权限为 `100644`,按其 shebang 直接执行会 `permission denied`;现改为 `100755`。直接执行通过(含临时测试库行为校验),`scripts/tests/pilot-export-contract.test.mjs` 通过 `5/5`;未修改业务数据。
|
||||||
- 2026-07-14 BRD 用户端回归复核:`mobile-uni` 类型检查通过,用户端单测 `53/53` 通过;源码中的“工作上报·建设中”属于 BRD 阶段二/三信息直达或北森/报事集成边界,候选人“等待后续通知”属于完成态提示,不新增一期空壳功能。测试进程曾输出既有 Vite WebSocket 端口占用警告,但测试退出码为 `0`,需在独立 CI/无并行开发服务环境再确认,不作为业务失败。
|
- 2026-07-14 BRD 用户端回归复核:`mobile-uni` 类型检查通过,用户端单测 `53/53` 通过;源码中的“工作上报·建设中”属于 BRD 阶段二/三信息直达或北森/报事集成边界,候选人“等待后续通知”属于完成态提示,不新增一期空壳功能。测试进程曾输出既有 Vite WebSocket 端口占用警告,但测试退出码为 `0`,需在独立 CI/无并行开发服务环境再确认,不作为业务失败。
|
||||||
- 2026-07-14 BRD 4.4 生产迁移顺序修复:每日三题评分模式迁移原先直接在 `score` 后添加 `score_mode`,旧生产表若缺少后来新增的 `score` 字段会迁移失败;现同一幂等脚本先补 `score`、再补 `score_mode`,并加入 `demo-check` marker。临时旧表连续执行两次迁移后得到 `score,score_mode`,未修改业务数据。
|
- 2026-07-14 BRD 4.4 生产迁移顺序修复:每日三题评分模式迁移原先直接在 `score` 后添加 `score_mode`,旧生产表若缺少后来新增的 `score` 字段会迁移失败;现同一幂等脚本先补 `score`、再补 `score_mode`,并加入 `demo-check` marker。临时旧表连续执行两次迁移后得到 `score,score_mode`,未修改业务数据。
|
||||||
|
- 2026-07-14 BRD 4.4/4.7 旧 schema 迁移兼容性修复:SOP 提问主体迁移原先默认旧表已有 `source` 列,入职日期迁移原先默认 `aihr_org_snapshot` 表已存在;现分别先按表/列存在性补 `source` 再补 `requester_ext_party_id`,并在组织表不存在或缺少 `employment_status` 时安全跳过定位依赖。两份迁移均保持幂等,不写入业务数据;新增 `demo-check` marker,后续用临时旧 schema 做连续执行验证。
|
||||||
|
- 2026-07-14 BRD 门禁夹具同步:严格预检已将 SOP 正式样本限定为带 `requester_ext_party_id` 且能命中在职组织身份的提问记录;原 `demo-check-pilot-gates` 临时表仍是旧 6 列,导致 SOP 指标为空并无法真实覆盖新口径。现补齐主体与 `prompt_version` 字段,使用安全员工主体 `E` 验证 `sop_usable=1/1`、待评审数和窗口过滤,未改变业务数据。
|
||||||
|
|||||||
@@ -530,6 +530,8 @@ contains backend/script/sql/update/aihr_20260714_practice_evidence_mysql8.sql "a
|
|||||||
contains backend/script/sql/update/aihr_20260714_practice_evidence_mysql8.sql "aihr_practice_calibration"
|
contains backend/script/sql/update/aihr_20260714_practice_evidence_mysql8.sql "aihr_practice_calibration"
|
||||||
contains backend/script/sql/aihr_org_snapshot_mysql8.sql "hire_date"
|
contains backend/script/sql/aihr_org_snapshot_mysql8.sql "hire_date"
|
||||||
contains backend/script/sql/update/aihr_20260714_org_hire_date_mysql8.sql "hire_date"
|
contains backend/script/sql/update/aihr_20260714_org_hire_date_mysql8.sql "hire_date"
|
||||||
|
contains backend/script/sql/update/aihr_20260714_org_hire_date_mysql8.sql "aihr_org_snapshot_table_exists"
|
||||||
|
contains backend/script/sql/update/aihr_20260714_sop_requester_identity_mysql8.sql "aihr_sop_source_exists"
|
||||||
contains backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/service/AihrOrgSyncService.java "hireDate"
|
contains backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/service/AihrOrgSyncService.java "hireDate"
|
||||||
contains frontend/src/api/aihr/practice.ts '/api/train/practice/scenarios/${id}/enabled'
|
contains frontend/src/api/aihr/practice.ts '/api/train/practice/scenarios/${id}/enabled'
|
||||||
contains backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/controller/AihrPracticeController.java "/scenarios/{id}/enabled"
|
contains backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/controller/AihrPracticeController.java "/scenarios/{id}/enabled"
|
||||||
|
|||||||
@@ -73,7 +73,8 @@ CREATE TABLE aihr_practice_calibration (
|
|||||||
);
|
);
|
||||||
CREATE TABLE aihr_sop_answer_review (
|
CREATE TABLE aihr_sop_answer_review (
|
||||||
tenant_id varchar(20), category varchar(100), status varchar(30), usable tinyint,
|
tenant_id varchar(20), category varchar(100), status varchar(30), usable tinyint,
|
||||||
reviewed_time datetime, create_time datetime
|
reviewed_time datetime, create_time datetime,
|
||||||
|
requester_ext_party_id varchar(100), prompt_version varchar(80)
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO aihr_practice_scenario
|
INSERT INTO aihr_practice_scenario
|
||||||
@@ -136,13 +137,15 @@ INSERT INTO aihr_practice_calibration (tenant_id,session_id,original_score,corre
|
|||||||
('000000','f-1',80,82,'2026-07-08 11:00:00'),
|
('000000','f-1',80,82,'2026-07-08 11:00:00'),
|
||||||
('000000','unsafe-inside',80,40,'2026-07-08 11:00:00'),
|
('000000','unsafe-inside',80,40,'2026-07-08 11:00:00'),
|
||||||
('000000','e-out',80,40,'2026-07-06 11:00:00');
|
('000000','e-out',80,40,'2026-07-06 11:00:00');
|
||||||
INSERT INTO aihr_sop_answer_review VALUES
|
INSERT INTO aihr_sop_answer_review
|
||||||
('000000','sop','已评审',1,'2026-07-08 12:00:00','2026-07-08 11:00:00'),
|
(tenant_id, category, status, usable, reviewed_time, create_time, requester_ext_party_id, prompt_version)
|
||||||
('000000','sop','已评审',0,'2026-07-06 12:00:00','2026-07-06 11:00:00'),
|
VALUES
|
||||||
('000000','sop','待评审',NULL,NULL,'2026-07-08 13:00:00'),
|
('000000','sop','已评审',1,'2026-07-08 12:00:00','2026-07-08 11:00:00','E','v1'),
|
||||||
('000000','training','已评审',0,'2026-07-08 12:30:00','2026-07-08 11:30:00'),
|
('000000','sop','已评审',0,'2026-07-06 12:00:00','2026-07-06 11:00:00','E','v1'),
|
||||||
('000000','training','待评审',NULL,NULL,'2026-07-08 13:00:00'),
|
('000000','sop','待评审',NULL,NULL,'2026-07-08 13:00:00','E','v1'),
|
||||||
('000000','training','待评审',NULL,NULL,'2026-07-06 13:00:00');
|
('000000','training','已评审',0,'2026-07-08 12:30:00','2026-07-08 11:30:00','E','v1'),
|
||||||
|
('000000','training','待评审',NULL,NULL,'2026-07-08 13:00:00','E','v1'),
|
||||||
|
('000000','training','待评审',NULL,NULL,'2026-07-06 13:00:00','E','v1');
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
export AIHR_PILOT_DB="$TEST_DB"
|
export AIHR_PILOT_DB="$TEST_DB"
|
||||||
|
|||||||
Reference in New Issue
Block a user