diff --git a/src/lib/db/suggest-change-store.ts b/src/lib/db/suggest-change-store.ts index e169e692292..f778a92f3fe 100644 --- a/src/lib/db/suggest-change-store.ts +++ b/src/lib/db/suggest-change-store.ts @@ -230,6 +230,8 @@ export class SuggestChangeStore implements ISuggestChangeStore { suggest_change_set_id: changeSetID, created_by: userId, }) + .onConflict(['action', 'suggest_change_set_id', 'feature']) + .merge() .returning('id'); }; diff --git a/src/migrations/20221810114644-add-suggest-changes-table.js b/src/migrations/20221810114644-add-suggest-changes-table.js index 058e71e8f3f..1b4450afbdb 100644 --- a/src/migrations/20221810114644-add-suggest-changes-table.js +++ b/src/migrations/20221810114644-add-suggest-changes-table.js @@ -19,7 +19,8 @@ CREATE TABLE IF NOT EXISTS suggest_change ( payload jsonb not null default '[]'::jsonb, created_by integer not null references users (id) ON DELETE CASCADE, created_at timestamp default now(), - suggest_change_set_id integer NOT NULL REFERENCES suggest_change_set(id) ON DELETE CASCADE + suggest_change_set_id integer NOT NULL REFERENCES suggest_change_set(id) ON DELETE CASCADE, + UNIQUE (feature, action, suggest_change_set_id) ); `, callback,