Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
前端: - store 改为 votedArtists[] + zustand persist - VoteModal 删除 1/3/5/ALL 选择器,改三态(待投/已投/满额) - 卡片/排行/详情页加 hasVoted 状态 + ✓ 角标 - Hero 右上角 Countdown 替换为 HeroVoteProgress(12 格点亮进度) - /me 改为终身额度叙事(QuotaCard / StatsGrid / MyFanSupport) 后端: - votes 表加 @@unique([userId, artistId])(已 apply 到生产 RDS) - /api/vote 重写:12 票上限 + P2002 ALREADY_VOTED + P2003 NOT_FOUND 兜底 - /api/me 新增 votedArtists[] + voteQuota,移除 dailyQuota - 新增 ERR.ALREADY_VOTED 错误码 测试: - DB 层 5/5 + E2E 18/18 通过(scripts/e2e-vote-flow.sh) - 修复 P2003 FK 违反未识别的 bug 详情见 docs/todo/voting-refactor-完成报告.md 与 voting-refactor-backend-完成报告.md Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
21 lines
1.1 KiB
SQL
21 lines
1.1 KiB
SQL
-- =====================================================
|
|
-- 投票模型从"每日额度"切换为"终身 12 票 + 每艺人 1 票"
|
|
-- 生成时间: 2026-05-15
|
|
-- 影响: votes 表
|
|
-- =====================================================
|
|
|
|
-- 1. 先加唯一约束:每个用户对每个艺人最多 1 票(DB 层硬约束)
|
|
-- 生产探查确认零重复 (userId, artistId),加约束不会失败
|
|
-- leading column 是 user_id,可作为 FK(votes.user_id → users.id)的索引基础
|
|
ALTER TABLE `votes` ADD UNIQUE INDEX `votes_user_id_artist_id_key` (`user_id`, `artist_id`);
|
|
|
|
-- 2. 删除旧的非唯一复合索引(userId, artistId, createdAt)
|
|
-- 新 unique 索引以 user_id 开头,已经能满足 FK 约束的 leading 索引要求
|
|
ALTER TABLE `votes` DROP INDEX `votes_user_id_artist_id_created_at_idx`;
|
|
|
|
-- =====================================================
|
|
-- 回滚 SQL(如需撤销)
|
|
-- ALTER TABLE `votes` ADD INDEX `votes_user_id_artist_id_created_at_idx` (`user_id`, `artist_id`, `created_at`);
|
|
-- ALTER TABLE `votes` DROP INDEX `votes_user_id_artist_id_key`;
|
|
-- =====================================================
|