-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: SQL 'DO UPDATE' syntax for data sync script (#2333)
- Loading branch information
1 parent
f7b84f3
commit c608dd8
Showing
5 changed files
with
41 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
-- insert team_members overwriting conflicts | ||
CREATE TEMPORARY TABLE sync_team_members ( | ||
id uuid, | ||
user_id integer, | ||
team_id integer, | ||
role text | ||
); | ||
|
||
\copy team_members FROM '/tmp/team_members.csv' WITH (FORMAT csv, DELIMITER ';'); | ||
\copy sync_team_members FROM '/tmp/team_members.csv' WITH (FORMAT csv, DELIMITER ';'); | ||
|
||
INSERT INTO | ||
team_members (id, user_id, team_id, role) | ||
SELECT | ||
id, user_id, team_id, role | ||
FROM | ||
sync_team_members ON CONFLICT (id) DO UPDATE; | ||
sync_team_members ON CONFLICT (id) DO UPDATE | ||
SET | ||
user_id = EXCLUDED.user_id, | ||
team_id = EXCLUDED.team_id, | ||
role = EXCLUDED.role; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters