fix(aihr): persist org hire dates

This commit is contained in:
2026-07-14 14:48:48 +08:00
parent 96a9cffc82
commit 3f39be7fee
8 changed files with 75 additions and 14 deletions
@@ -16,6 +16,7 @@ CREATE TABLE `aihr_org_snapshot` (
`position_name` varchar(100) DEFAULT NULL COMMENT '岗位',
`position_level` varchar(30) DEFAULT NULL COMMENT '岗位层级(一线/主管/项目经理)',
`employment_status` varchar(20) DEFAULT 'active' COMMENT '在职状态',
`hire_date` date DEFAULT NULL COMMENT '入职日期(用于新员工三个月资格判断)',
`snapshot_date` date DEFAULT NULL COMMENT '快照日期',
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
PRIMARY KEY (`id`),
@@ -0,0 +1,17 @@
-- AIHR 组织快照入职日期迁移(MySQL 8.x)
-- 仅补齐结构,不写入业务数据;可重复执行。
SET @aihr_hire_date_exists := (
SELECT COUNT(*)
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'aihr_org_snapshot'
AND COLUMN_NAME = 'hire_date'
);
SET @aihr_hire_date_ddl := IF(
@aihr_hire_date_exists = 0,
'ALTER TABLE aihr_org_snapshot ADD COLUMN `hire_date` date DEFAULT NULL COMMENT ''入职日期(用于新员工三个月资格判断)'' AFTER `employment_status`',
'SELECT 1'
);
PREPARE aihr_hire_date_stmt FROM @aihr_hire_date_ddl;
EXECUTE aihr_hire_date_stmt;
DEALLOCATE PREPARE aihr_hire_date_stmt;