Files
ruoyi-java/sql/jarvis_tg_scalper_phone_phones_json_upgrade.sql
2026-05-09 23:27:52 +08:00

22 lines
829 B
SQL
Raw 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.
-- 已从单列 phone 升级为 phones JSON 数组的库执行此脚本(仅迁移,不含建表)
-- 执行前请备份。
ALTER TABLE `jarvis_tg_scalper_phone`
ADD COLUMN `phones` JSON NULL COMMENT '11位手机号JSON数组' AFTER `id`;
UPDATE `jarvis_tg_scalper_phone`
SET `phones` = JSON_ARRAY(`phone`)
WHERE `phones` IS NULL AND `phone` IS NOT NULL AND `phone` != '';
UPDATE `jarvis_tg_scalper_phone`
SET `phones` = JSON_ARRAY()
WHERE `phones` IS NULL;
-- 若建表时未建唯一索引 uk_phone请跳过本句或改为你的实际索引名
ALTER TABLE `jarvis_tg_scalper_phone` DROP INDEX `uk_phone`;
ALTER TABLE `jarvis_tg_scalper_phone` DROP COLUMN `phone`;
ALTER TABLE `jarvis_tg_scalper_phone`
MODIFY COLUMN `phones` JSON NOT NULL COMMENT '11位手机号JSON数组如 ["13800138000","13900139000"]';