Skip to content

Commit

Permalink
chore(wip): Update sync script for team_themes table (#2633)
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr authored Jan 8, 2024
1 parent 59d016a commit c9b7810
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scripts/seed-database/container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mkdir -p /tmp
# Create sync.sql file for all our comnands which will be executed in a single transaction
touch '/tmp/sync.sql'

tables=(flows users teams flow_document_templates team_members)
tables=(flows users teams flow_document_templates team_members team_themes)

# run copy commands on remote db
for table in "${tables[@]}"; do
Expand Down
3 changes: 2 additions & 1 deletion scripts/seed-database/write/main.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
\include write/flow_document_templates.sql
\include write/published_flows.sql
\include write/team_members.sql
\include write/team_integrations.sql
\include write/team_integrations.sql
\include write/team_themes.sql
41 changes: 41 additions & 0 deletions scripts/seed-database/write/team_themes.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
-- insert teams_themes overwriting conflicts
CREATE TEMPORARY TABLE sync_team_themes (
id integer,
team_id integer,
primary_colour text,
secondary_colour text,
logo text,
favicon text
);

\copy sync_team_themes FROM '/tmp/team_themes.csv' WITH (FORMAT csv, DELIMITER ';');

INSERT INTO
team_themes (
id,
team_id,
primary_colour,
secondary_colour,
logo,
favicon
)
SELECT
id,
team_id,
primary_colour,
secondary_colour,
logo,
favicon
FROM
sync_team_themes ON CONFLICT (id) DO
UPDATE
SET
team_id = EXCLUDED.team_id,
primary_colour = EXCLUDED.primary_colour,
secondary_colour = EXCLUDED.secondary_colour,
logo = EXCLUDED.logo,
favicon = EXCLUDED.favicon;
SELECT
setval('team_themes_id_seq', max(id))
FROM
team_themes;
2 changes: 0 additions & 2 deletions scripts/seed-database/write/teams.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ CREATE TEMPORARY TABLE sync_teams (
id integer,
name text,
slug text,
-- TODO: Drop this and fetch from team_themes
theme jsonb,
created_at timestamptz,
updated_at timestamptz,
settings jsonb,
Expand Down

0 comments on commit c9b7810

Please sign in to comment.