React forms DB

forms_submission_value must have unique (submission_id, attribute). 
otherwise, in multi-step forms, when returning from the next step, the values ​​will be re-entered and not overwritten.

ALTER TABLE forms_submission_value
ADD UNIQUE KEY uniq_submission_attribute (submission_id, attribute);

If there are duplicities remove them:

DELETE f   (or SELECT * for test)
FROM forms_submission_value f
JOIN (
    SELECT MAX(id) AS keep_id, submission_id, attribute
    FROM forms_submission_value
    GROUP BY submission_id, attribute
    HAVING COUNT(*) > 1
) x
  ON f.submission_id = x.submission_id
 AND f.attribute = x.attribute
WHERE f.id > x.keep_id;

 

Rate this FAQ

0 (0 Votes)