38 lines
1.6 KiB
SQL
38 lines
1.6 KiB
SQL
-- Migration guide for the shared-token template split.
|
|
-- Review rows before running against a production database. This script does
|
|
-- not move or retain Henan Lelian credentials.
|
|
SET NAMES utf8mb4;
|
|
|
|
-- 1. Inspect the archived template and its channels.
|
|
SELECT temp_key, temp_model, temp_config
|
|
FROM t_sim_channel_template
|
|
WHERE temp_key = 'sim_onelink_shared_v5';
|
|
|
|
SELECT chan_key, chan_config, chan_status
|
|
FROM t_sim_channels
|
|
WHERE temp_key = 'sim_onelink_shared_v5';
|
|
|
|
-- 2. Seed the new templates first (see seed_onelink_shared_channel.sql),
|
|
-- then migrate only Tengyu rows after reviewing their provider value.
|
|
-- The JSON functions require MySQL 5.7+ and intentionally preserve only the
|
|
-- channel credentials. Public API/provider settings live in the new template.
|
|
UPDATE t_sim_channels
|
|
SET temp_key = 'sim_onelink_tengyu_v1',
|
|
chan_config = JSON_OBJECT(
|
|
'credentials', JSON_OBJECT(
|
|
'pwdKey', JSON_UNQUOTE(JSON_EXTRACT(chan_config, '$.auth.pwdKey')),
|
|
'channelNo', JSON_UNQUOTE(JSON_EXTRACT(chan_config, '$.auth.channelNo'))
|
|
)
|
|
)
|
|
WHERE temp_key = 'sim_onelink_shared_v5'
|
|
AND LOWER(JSON_UNQUOTE(JSON_EXTRACT(chan_config, '$.auth.provider'))) = 'tengyu';
|
|
|
|
-- 3. Henan Lelian rows must be disabled and manually migrated or removed.
|
|
UPDATE t_sim_channels
|
|
SET chan_status = 0
|
|
WHERE temp_key = 'sim_onelink_shared_v5'
|
|
AND LOWER(JSON_UNQUOTE(JSON_EXTRACT(chan_config, '$.auth.provider'))) = 'henan_lelian';
|
|
|
|
-- 4. After all rows are reviewed and migrated, remove the archived template.
|
|
-- DELETE FROM t_sim_channel_template WHERE temp_key = 'sim_onelink_shared_v5';
|