Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update sync script for team_themes table #2633

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading