fix(aihr): make daily score migration backward compatible

This commit is contained in:
2026-07-14 16:09:06 +08:00
parent 4f7487fdf6
commit 638f231d0c
3 changed files with 18 additions and 0 deletions
@@ -6,6 +6,22 @@ SET @table_exists = (
WHERE table_schema = @db_name
AND table_name = 'aihr_practice_assignment'
);
SET @score_column_exists = (
SELECT COUNT(*)
FROM information_schema.columns
WHERE table_schema = @db_name
AND table_name = 'aihr_practice_assignment'
AND column_name = 'score'
);
SET @score_ddl = IF(
@table_exists = 1 AND @score_column_exists = 0,
'ALTER TABLE aihr_practice_assignment ADD COLUMN score int DEFAULT NULL COMMENT ''每日三题得分''',
'SELECT 1'
);
PREPARE score_stmt FROM @score_ddl;
EXECUTE score_stmt;
DEALLOCATE PREPARE score_stmt;
SET @column_exists = (
SELECT COUNT(*)
FROM information_schema.columns