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:
2026-05-18 22:55:21 -04:00
parent 087becdf58
commit fe5cdd92a1
4 changed files with 186 additions and 0 deletions
+2
View File
@@ -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)