Files
API/sql/feedback/003_add_submission_client_token.sql
T
PaddyandClaude Opus 5.5 adf723419d
Test and deploy / test-and-deploy (pull_request) Successful in 27s
Match a submission's client token only within its event
The token is per form visit, and one visit can move on to another
concert's form in the same tab. With a global match, the second event's
submission was answered with the first event's id and its feedback was
silently dropped. The lookup now joins on the event slug, and the unique
index in 003 is (event_id, client_token) instead of client_token alone.

003 is edited in place: it has not been applied anywhere yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 18:27:27 +01:00

18 lines
1010 B
SQL

-- Nachklang e.V. Feedback module — makes submitting idempotent per form visit.
-- Apply manually against the FEEDBACK_DB database, after 002_add_poster_image_url.sql:
-- mysql -h <DB_HOST> -u <DB_USER> -p <FEEDBACK_DB> < 003_add_submission_client_token.sql
--
-- The form generates one UUID per visit and resends it on every retry. When
-- a submission saved but its response never reached the phone, the visitor
-- sees an error and taps "absenden" again; the API now finds the stored token
-- and answers with the original submission instead of saving a copy.
--
-- Unique per event, not globally: one visit can switch to another concert's
-- form in the same tab, and that event's submission must still save.
--
-- NULL for every row written before this migration and for any client that
-- sends no token; a UNIQUE index allows any number of NULLs.
ALTER TABLE submissions
ADD COLUMN client_token CHAR(36) NULL AFTER ip_hash,
ADD UNIQUE KEY uq_sub_event_client_token (event_id, client_token);