-- 已从单列 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"]';
