Dedupe RSVPs and add tests for auto-RSVP on claim
Add migration to clean up duplicate RSVPs (keep earliest per event+name). Add GetRsvpByName and DeleteDuplicateRsvps queries. Tests cover auto-RSVP creation, duplicate prevention, and case-insensitive matching. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,8 @@ func runMigrations(database *sql.DB) {
|
||||
// Indexes for auth tables (created here so they run after column migrations).
|
||||
`CREATE INDEX IF NOT EXISTS idx_sessions_user ON sessions(user_id)`,
|
||||
`CREATE INDEX IF NOT EXISTS idx_verification_codes_identifier ON verification_codes(identifier)`,
|
||||
// Dedupe RSVPs: keep earliest per (event_id, name).
|
||||
`DELETE FROM rsvps WHERE id NOT IN (SELECT MIN(id) FROM rsvps GROUP BY event_id, name COLLATE NOCASE)`,
|
||||
}
|
||||
for _, m := range migrations {
|
||||
_, err := database.Exec(m)
|
||||
|
||||
Reference in New Issue
Block a user