admin/sql/migrate_notice_receiver_ids_text.sql
zzh 7a0affe2d4
All checks were successful
Build and Deploy / deploy (push) Successful in 1m1s
fix: 公告广播可见性改为反序列化判定,避免 JSON 列比较失败
ReceiverIds 改为 text 存储并补充迁移;广播对客户/收件箱可见。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-16 09:57:25 +08:00

26 lines
883 B
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- =============================================================================
-- migrate_notice_receiver_ids_text.sql
-- t_notice.ReceiverIds:JSON → TEXT,保证广播([])与定向名单可用字符串条件查询
-- 可重复执行
-- =============================================================================
SET @db := DATABASE();
SET @col_type := (
SELECT DATA_TYPE
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db
AND TABLE_NAME = 't_notice'
AND COLUMN_NAME = 'ReceiverIds'
LIMIT 1
);
SET @sql := IF(
@col_type IS NOT NULL AND LOWER(IFNULL(@col_type, '')) = 'json',
'ALTER TABLE `t_notice`
MODIFY COLUMN `ReceiverIds` TEXT NOT NULL COMMENT ''接收对象ID列表(JSON数组字符串)''',
'SELECT ''t_notice.ReceiverIds already text or missing'' AS info'
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;