fix(aihr): version practice session evidence migration
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
-- AIHR 对练会话证据字段迁移(MySQL 8.x)
|
||||
-- 补齐严格试点门禁要求的 5 个会话证据字段;不写入业务数据,可重复执行。
|
||||
|
||||
SET @aihr_practice_session_table_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.TABLES
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'aihr_practice_session'
|
||||
);
|
||||
|
||||
SET @aihr_session_annotations_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'aihr_practice_session'
|
||||
AND COLUMN_NAME = 'annotations_json'
|
||||
);
|
||||
SET @aihr_session_annotations_ddl := IF(
|
||||
@aihr_practice_session_table_exists = 1 AND @aihr_session_annotations_exists = 0,
|
||||
'ALTER TABLE aihr_practice_session ADD COLUMN `annotations_json` text DEFAULT NULL COMMENT ''逐句标注JSON''',
|
||||
'SELECT 1'
|
||||
);
|
||||
PREPARE aihr_session_annotations_stmt FROM @aihr_session_annotations_ddl;
|
||||
EXECUTE aihr_session_annotations_stmt;
|
||||
DEALLOCATE PREPARE aihr_session_annotations_stmt;
|
||||
|
||||
SET @aihr_session_review_advice_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'aihr_practice_session'
|
||||
AND COLUMN_NAME = 'review_advice'
|
||||
);
|
||||
SET @aihr_session_review_advice_ddl := IF(
|
||||
@aihr_practice_session_table_exists = 1 AND @aihr_session_review_advice_exists = 0,
|
||||
'ALTER TABLE aihr_practice_session ADD COLUMN `review_advice` varchar(1000) DEFAULT NULL COMMENT ''主管复盘建议''',
|
||||
'SELECT 1'
|
||||
);
|
||||
PREPARE aihr_session_review_advice_stmt FROM @aihr_session_review_advice_ddl;
|
||||
EXECUTE aihr_session_review_advice_stmt;
|
||||
DEALLOCATE PREPARE aihr_session_review_advice_stmt;
|
||||
|
||||
SET @aihr_session_incentive_point_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'aihr_practice_session'
|
||||
AND COLUMN_NAME = 'incentive_point'
|
||||
);
|
||||
SET @aihr_session_incentive_point_ddl := IF(
|
||||
@aihr_practice_session_table_exists = 1 AND @aihr_session_incentive_point_exists = 0,
|
||||
'ALTER TABLE aihr_practice_session ADD COLUMN `incentive_point` int DEFAULT NULL COMMENT ''主管人工贡献分''',
|
||||
'SELECT 1'
|
||||
);
|
||||
PREPARE aihr_session_incentive_point_stmt FROM @aihr_session_incentive_point_ddl;
|
||||
EXECUTE aihr_session_incentive_point_stmt;
|
||||
DEALLOCATE PREPARE aihr_session_incentive_point_stmt;
|
||||
|
||||
SET @aihr_session_satisfaction_score_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'aihr_practice_session'
|
||||
AND COLUMN_NAME = 'satisfaction_score'
|
||||
);
|
||||
SET @aihr_session_satisfaction_score_ddl := IF(
|
||||
@aihr_practice_session_table_exists = 1 AND @aihr_session_satisfaction_score_exists = 0,
|
||||
'ALTER TABLE aihr_practice_session ADD COLUMN `satisfaction_score` tinyint DEFAULT NULL COMMENT ''员工训练满意度1-5分''',
|
||||
'SELECT 1'
|
||||
);
|
||||
PREPARE aihr_session_satisfaction_score_stmt FROM @aihr_session_satisfaction_score_ddl;
|
||||
EXECUTE aihr_session_satisfaction_score_stmt;
|
||||
DEALLOCATE PREPARE aihr_session_satisfaction_score_stmt;
|
||||
|
||||
SET @aihr_session_satisfaction_comment_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'aihr_practice_session'
|
||||
AND COLUMN_NAME = 'satisfaction_comment'
|
||||
);
|
||||
SET @aihr_session_satisfaction_comment_ddl := IF(
|
||||
@aihr_practice_session_table_exists = 1 AND @aihr_session_satisfaction_comment_exists = 0,
|
||||
'ALTER TABLE aihr_practice_session ADD COLUMN `satisfaction_comment` varchar(500) DEFAULT NULL COMMENT ''员工训练满意度意见''',
|
||||
'SELECT 1'
|
||||
);
|
||||
PREPARE aihr_session_satisfaction_comment_stmt FROM @aihr_session_satisfaction_comment_ddl;
|
||||
EXECUTE aihr_session_satisfaction_comment_stmt;
|
||||
DEALLOCATE PREPARE aihr_session_satisfaction_comment_stmt;
|
||||
Reference in New Issue
Block a user