1198ecc556
集成分支曾把已上线的 000020_ad_bonus_minutes(#21)/000021_devices_user_scoped_uuid(#27) 两个迁移错误覆盖成 codes_lib_legacy_rename/pay_purchases,与生产(schema_migrations=21) 的实际血统冲突,导致 golang-migrate 在生产上找不到 version 21 文件而报错。 恢复为:020 ad_bonus / 021 devices / 022 codes_lib_legacy_rename / 023 pay_purchases。 生产库副本完整试跑通过:version→23,pay_purchases 建好,subscriptions CHECK 加 'pay', codes 库表就位,3 用户/3 订阅数据零丢失。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013nMthbVEmQquxBRKb9Fj8u
13 lines
472 B
SQL
13 lines
472 B
SQL
-- 回退:UNIQUE(user_id,uuid) → 全局 UNIQUE(uuid),platform ENUM 去掉 linux。
|
|
-- 有损:同一 uuid 跨用户的重复行只保留最早一行(id 最小),linux 平台行删除。
|
|
|
|
DELETE d1 FROM devices d1
|
|
JOIN devices d2 ON d1.uuid = d2.uuid AND d1.id > d2.id;
|
|
|
|
DELETE FROM devices WHERE platform = 'linux';
|
|
|
|
ALTER TABLE devices
|
|
DROP INDEX uniq_devices_user_uuid,
|
|
ADD UNIQUE KEY uuid (uuid),
|
|
MODIFY platform ENUM('ios','android','windows','macos') NOT NULL;
|