Test and deploy / test-and-deploy (pull_request) Successful in 46s
When a submission saved but its response never reached the phone, the form showed an error, the visitor tapped "Feedback absenden" again, and a second identical row was stored (seen twice in production: 82/83, 87/88). The form now sends a clientToken, one UUID per visit, on every attempt. A token that is already stored returns the original submissionId and saves nothing; the lookup runs before the eligibility check, so a retry still succeeds if the feedback window closed in between. Two concurrent retries are settled by a UNIQUE index on submissions.client_token: the loser gets ER_DUP_ENTRY, rolls back and returns the winner's id. A missing or non-UUID token behaves as before, so cached copies of the old form still submit. Migration 003 must be applied before this is deployed - the INSERT now writes client_token. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
15 lines
844 B
SQL
15 lines
844 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.
|
|
--
|
|
-- 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_client_token (client_token);
|