diff --git a/hasura.planx.uk/metadata/tables.yaml b/hasura.planx.uk/metadata/tables.yaml index e920555a75..bc532a857d 100644 --- a/hasura.planx.uk/metadata/tables.yaml +++ b/hasura.planx.uk/metadata/tables.yaml @@ -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: diff --git a/scripts/seed-database/container.sh b/scripts/seed-database/container.sh index a4c369f8cd..03390220ad 100755 --- a/scripts/seed-database/container.sh +++ b/scripts/seed-database/container.sh @@ -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 diff --git a/scripts/seed-database/write/main.sql b/scripts/seed-database/write/main.sql index 4a75095dfd..a3c284c12f 100644 --- a/scripts/seed-database/write/main.sql +++ b/scripts/seed-database/write/main.sql @@ -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 \ No newline at end of file diff --git a/scripts/seed-database/write/team_settings.sql b/scripts/seed-database/write/team_settings.sql new file mode 100644 index 0000000000..1278dac0aa --- /dev/null +++ b/scripts/seed-database/write/team_settings.sql @@ -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; \ No newline at end of file