11 lines
841 B
MySQL
11 lines
841 B
MySQL
|
|
-- 站内信消息等级:通用消息表加 level 列(1普通/2提醒/3警告/4严重,默认普通)
|
|||
|
|
-- 设计见 docs/superpowers/specs/2026-06-13-告警消息等级-design.md
|
|||
|
|
-- 幂等:MySQL 不支持 ADD COLUMN IF NOT EXISTS,用 information_schema 判断后 PREPARE 执行
|
|||
|
|
-- 列定义/注释须与演示库补丁 docs/sql/patches/2026-06-13-告警消息等级-01.sql 块1 保持一致
|
|||
|
|
SET @col_exists = (SELECT COUNT(*) FROM information_schema.columns
|
|||
|
|
WHERE table_schema = DATABASE() AND table_name = 'system_notify_message' AND column_name = 'level');
|
|||
|
|
SET @ddl = IF(@col_exists = 0,
|
|||
|
|
'ALTER TABLE system_notify_message ADD COLUMN level TINYINT NOT NULL DEFAULT 1 COMMENT ''消息等级:1普通/2提醒/3警告/4严重'' AFTER read_time',
|
|||
|
|
'SELECT 1');
|
|||
|
|
PREPARE stmt FROM @ddl; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|