fix(aihr): make daily score migration backward compatible
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user