Skip to content

Commit

Permalink
feat: add scripts for pulling team_settings data from production (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
RODO94 authored Jun 26, 2024
1 parent 579be6e commit be6a176
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 0 deletions.
7 changes: 7 additions & 0 deletions hasura.planx.uk/metadata/tables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1856,6 +1856,13 @@
table:
name: team_integrations
schema: public
- name: team_settings
using:
foreign_key_constraint_on:
column: team_id
table:
name: team_settings
schema: public
- name: theme
using:
foreign_key_constraint_on:
Expand Down
1 change: 1 addition & 0 deletions scripts/seed-database/container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ tables=(
flow_document_templates
team_members
team_themes
team_settings
# Optional tables
# Please comment in if working on a feature and you require example data locally
# You will need to manually grant select permissions to the github_actions on production, and update main.sql
Expand Down
1 change: 1 addition & 0 deletions scripts/seed-database/write/main.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
\include write/team_members.sql
\include write/team_integrations.sql
\include write/team_themes.sql
\include write/team_settings.sql

-- Optional tables
-- \include write/feedback.sql
65 changes: 65 additions & 0 deletions scripts/seed-database/write/team_settings.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
-- insert teams_settings overwriting conflicts
CREATE TEMPORARY TABLE sync_team_settings (
id integer,
team_id integer,
reference_code text,
homepage text,
help_email text,
help_phone text,
help_opening_hours text,
email_reply_to_id text,
external_planning_site_url text,
external_planning_site_name text,
boundary_url text,
boundary_json jsonb
);

\copy sync_team_settings FROM '/tmp/team_settings.csv' WITH (FORMAT csv, DELIMITER ';');

INSERT INTO
team_settings (
id,
team_id,
reference_code,
homepage,
help_email,
help_phone,
help_opening_hours,
email_reply_to_id,
external_planning_site_url,
external_planning_site_name,
boundary_url,
boundary_json
)
SELECT
id,
team_id,
reference_code,
homepage,
help_email,
help_phone,
help_opening_hours,
email_reply_to_id,
external_planning_site_url,
external_planning_site_name,
boundary_url,
boundary_json
FROM
sync_team_settings ON CONFLICT (id) DO
UPDATE
SET
team_id = EXCLUDED.team_id,
reference_code = EXCLUDED.reference_code,
homepage = EXCLUDED.homepage,
help_email = EXCLUDED.help_email,
help_phone = EXCLUDED.help_phone,
help_opening_hours = EXCLUDED.help_opening_hours,
email_reply_to_id = EXCLUDED.email_reply_to_id,
external_planning_site_url = EXCLUDED.external_planning_site_url,
external_planning_site_name = EXCLUDED.external_planning_site_name,
boundary_url = EXCLUDED.boundary_url,
boundary_json = EXCLUDED.boundary_json;
SELECT
setval('team_settings_id_seq', max(id))
FROM
team_settings;

0 comments on commit be6a176

Please sign in to comment.