Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions data/migrations/0014_narrow_wind_dancer.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DROP INDEX `event_winner_event_id_room_index_user_id_unique`;--> statement-breakpoint
CREATE UNIQUE INDEX `event_winner_event_id_user_id_unique` ON `event_winner` (`event_id`,`user_id`);--> statement-breakpoint
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Deduplicate winners before adding unique index

This migration fails on any existing database where the same user was declared a winner for multiple rooms in the same event, which the previous (event_id, room_index, user_id) unique constraint explicitly allowed. When such rows exist, CREATE UNIQUE INDEX ... (event_id, user_id) raises a uniqueness error before room_index is dropped, so the bot cannot migrate/start for those guilds; add a data-migration step to collapse or delete duplicates before creating the new unique index.

Useful? React with 👍 / 👎.

ALTER TABLE `event_winner` DROP COLUMN `room_index`;
Loading