From 102393e989978c9cf691c2adbcad1faea08ecd14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Tue, 17 Oct 2023 10:08:26 +0100 Subject: [PATCH] fix: Disable grant_new_user_template_team_access trigger in DB sync (#2315) --- scripts/seed-database/write/users.sql | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/seed-database/write/users.sql b/scripts/seed-database/write/users.sql index d814f880fc..adcd172074 100644 --- a/scripts/seed-database/write/users.sql +++ b/scripts/seed-database/write/users.sql @@ -11,6 +11,11 @@ CREATE TEMPORARY TABLE sync_users ( \copy sync_users FROM '/tmp/users.csv' WITH (FORMAT csv, DELIMITER ';'); +-- Do not automatically generate team_member records for the templates team +-- We manually truncate and replace the team_members table in another step +ALTER TABLE + users DISABLE TRIGGER grant_new_user_template_team_access; + INSERT INTO users ( id, first_name, @@ -27,4 +32,7 @@ SELECT FROM sync_users ON CONFLICT (id) DO NOTHING; +ALTER TABLE + users ENABLE TRIGGER grant_new_user_template_team_access; + SELECT setval('users_id_seq', max(id)) FROM users;