diff --git a/scripts/seed-database/container.sh b/scripts/seed-database/container.sh index 4789a3e33c..b7327d453e 100755 --- a/scripts/seed-database/container.sh +++ b/scripts/seed-database/container.sh @@ -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 diff --git a/scripts/seed-database/write/main.sql b/scripts/seed-database/write/main.sql index f39a94cb10..5ae353a990 100644 --- a/scripts/seed-database/write/main.sql +++ b/scripts/seed-database/write/main.sql @@ -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 \ No newline at end of file +\include write/team_integrations.sql +\include write/team_themes.sql \ No newline at end of file diff --git a/scripts/seed-database/write/team_themes.sql b/scripts/seed-database/write/team_themes.sql new file mode 100644 index 0000000000..68b42ebfe0 --- /dev/null +++ b/scripts/seed-database/write/team_themes.sql @@ -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; \ No newline at end of file diff --git a/scripts/seed-database/write/teams.sql b/scripts/seed-database/write/teams.sql index fcecd7cc85..7cc3c73dde 100644 --- a/scripts/seed-database/write/teams.sql +++ b/scripts/seed-database/write/teams.sql @@ -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,