From e01cae5d4ca0a35f4956b0083672cd5e176c00df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Thu, 19 Oct 2023 11:24:20 +0100 Subject: [PATCH] chore: Overwrite records on data-sync conflict --- scripts/seed-database/write/flows.sql | 2 +- scripts/seed-database/write/published_flows.sql | 2 +- scripts/seed-database/write/team_members.sql | 2 +- scripts/seed-database/write/teams.sql | 2 +- scripts/seed-database/write/users.sql | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/seed-database/write/flows.sql b/scripts/seed-database/write/flows.sql index 84d82bbe45..e6f431f5ca 100644 --- a/scripts/seed-database/write/flows.sql +++ b/scripts/seed-database/write/flows.sql @@ -34,7 +34,7 @@ SELECT settings, copied_from FROM sync_flows -ON CONFLICT (id) DO NOTHING; +ON CONFLICT (id) DO UPDATE; -- ensure that original flows.version is overwritten to match new operation inserted below, else sharedb will fail UPDATE flows SET version = 1; diff --git a/scripts/seed-database/write/published_flows.sql b/scripts/seed-database/write/published_flows.sql index ecc6de503b..2cf9d0a48c 100644 --- a/scripts/seed-database/write/published_flows.sql +++ b/scripts/seed-database/write/published_flows.sql @@ -25,4 +25,4 @@ SELECT publisher_id, created_at FROM sync_published_flows -ON CONFLICT (id) DO NOTHING; +ON CONFLICT (id) DO UPDATE; diff --git a/scripts/seed-database/write/team_members.sql b/scripts/seed-database/write/team_members.sql index 1e9d2de0bc..6f1a2dfeb1 100644 --- a/scripts/seed-database/write/team_members.sql +++ b/scripts/seed-database/write/team_members.sql @@ -12,4 +12,4 @@ INSERT INTO SELECT id, user_id, team_id, role FROM - sync_team_members ON CONFLICT (id) DO NOTHING; \ No newline at end of file + sync_team_members ON CONFLICT (id) DO UPDATE; \ No newline at end of file diff --git a/scripts/seed-database/write/teams.sql b/scripts/seed-database/write/teams.sql index 996e630f5e..a798aaff8f 100644 --- a/scripts/seed-database/write/teams.sql +++ b/scripts/seed-database/write/teams.sql @@ -33,6 +33,6 @@ SELECT notify_personalisation, boundary FROM sync_teams -ON CONFLICT (id) DO NOTHING; +ON CONFLICT (id) DO UPDATE; SELECT setval('teams_id_seq', max(id)) FROM teams; diff --git a/scripts/seed-database/write/users.sql b/scripts/seed-database/write/users.sql index adcd172074..ee4444ae94 100644 --- a/scripts/seed-database/write/users.sql +++ b/scripts/seed-database/write/users.sql @@ -30,7 +30,7 @@ SELECT email, is_platform_admin FROM sync_users -ON CONFLICT (id) DO NOTHING; +ON CONFLICT (id) DO UPDATE; ALTER TABLE users ENABLE TRIGGER grant_new_user_template_team_access;