From 8ec39471bdae49dfad689be83d7d5ce20a3af336 Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Tue, 18 Jun 2024 17:55:25 +0100 Subject: [PATCH 01/10] init hasura work for new team settings table --- hasura.planx.uk/metadata/tables.yaml | 109 ++++++++++++++++++ .../down.sql | 1 + .../up.sql | 16 +++ .../down.sql | 17 +++ .../up.sql | 15 +++ 5 files changed, 158 insertions(+) create mode 100644 hasura.planx.uk/migrations/1718719894002_create_table_public_team_settings/down.sql create mode 100644 hasura.planx.uk/migrations/1718719894002_create_table_public_team_settings/up.sql create mode 100644 hasura.planx.uk/migrations/1718728257637_populate_team_settings_table/down.sql create mode 100644 hasura.planx.uk/migrations/1718728257637_populate_team_settings_table/up.sql diff --git a/hasura.planx.uk/metadata/tables.yaml b/hasura.planx.uk/metadata/tables.yaml index cd5f0e6376..68c77be20e 100644 --- a/hasura.planx.uk/metadata/tables.yaml +++ b/hasura.planx.uk/metadata/tables.yaml @@ -1649,6 +1649,115 @@ - role: platformAdmin permission: filter: {} +- table: + name: team_settings + schema: public + select_permissions: + - role: api + permission: + columns: + - has_planning_data + - id + - team_id + - boundary_json + - boundary_url + - email_reply_to_id + - external_planning_site_name + - external_planning_site_url + - help_email + - help_opening_hours + - help_phone + - homepage + - reference_code + filter: {} + comment: "" + - role: platformAdmin + permission: + columns: + - has_planning_data + - id + - team_id + - boundary_json + - boundary_url + - email_reply_to_id + - external_planning_site_name + - external_planning_site_url + - help_email + - help_opening_hours + - help_phone + - homepage + - reference_code + filter: {} + comment: "" + - role: public + permission: + columns: + - has_planning_data + - id + - team_id + - boundary_json + - boundary_url + - email_reply_to_id + - external_planning_site_name + - external_planning_site_url + - help_email + - help_opening_hours + - help_phone + - homepage + - reference_code + filter: {} + comment: "" + - role: teamEditor + permission: + columns: + - has_planning_data + - id + - team_id + - boundary_json + - boundary_url + - email_reply_to_id + - external_planning_site_name + - external_planning_site_url + - help_email + - help_opening_hours + - help_phone + - homepage + - reference_code + filter: {} + comment: "" + update_permissions: + - role: platformAdmin + permission: + columns: + - boundary_url + - email_reply_to_id + - external_planning_site_name + - external_planning_site_url + - has_planning_data + - help_email + - help_opening_hours + - help_phone + - homepage + - reference_code + filter: {} + check: null + comment: "" + - role: teamEditor + permission: + columns: + - boundary_url + - email_reply_to_id + - external_planning_site_name + - external_planning_site_url + - has_planning_data + - help_email + - help_opening_hours + - help_phone + - homepage + - reference_code + filter: {} + check: null + comment: "" - table: name: team_themes schema: public diff --git a/hasura.planx.uk/migrations/1718719894002_create_table_public_team_settings/down.sql b/hasura.planx.uk/migrations/1718719894002_create_table_public_team_settings/down.sql new file mode 100644 index 0000000000..29fc26cbc2 --- /dev/null +++ b/hasura.planx.uk/migrations/1718719894002_create_table_public_team_settings/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."team_settings"; diff --git a/hasura.planx.uk/migrations/1718719894002_create_table_public_team_settings/up.sql b/hasura.planx.uk/migrations/1718719894002_create_table_public_team_settings/up.sql new file mode 100644 index 0000000000..00978c3922 --- /dev/null +++ b/hasura.planx.uk/migrations/1718719894002_create_table_public_team_settings/up.sql @@ -0,0 +1,16 @@ +CREATE TABLE "public"."team_settings" ("id" serial NOT NULL, +"team_id" integer NOT NULL, +"reference_code" text, +"homepage" text, +"help_email" text NOT NULL DEFAULT 'example@council.gov.uk', +"help_phone" text NOT NULL DEFAULT '(01234) 567890', +"help_opening_hours" text NOT NULL DEFAULT 'Monday - Friday, 9am - 5pm', +"email_reply_to_id" text NOT NULL DEFAULT '727d48fa-cb8a-42f9-b8b2-55032f3bb451', +"has_planning_data" boolean NOT NULL DEFAULT False, +"external_planning_site_url" text DEFAULT 'https://www.planningportal.co.uk/', +"external_planning_site_name" text DEFAULT 'Planning Portal', +"boundary_json" jsonb NOT NULL DEFAULT '{"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [[[1.9134116, 49.528423], [1.9134116, 61.331151], [1.9134116, 61.331151], [-10.76418, 61.331151], [-10.76418, 49.528423]]]}, "properties": {}}'::jsonb, "boundary_url" text, +PRIMARY KEY ("id") , +FOREIGN KEY ("team_id") REFERENCES "public"."teams"("id") ON UPDATE cascade ON DELETE cascade, +UNIQUE ("id"), UNIQUE ("team_id"), UNIQUE ("reference_code")); +COMMENT ON TABLE "public"."team_settings" IS E'Global settings for boundary and contact details'; diff --git a/hasura.planx.uk/migrations/1718728257637_populate_team_settings_table/down.sql b/hasura.planx.uk/migrations/1718728257637_populate_team_settings_table/down.sql new file mode 100644 index 0000000000..e1621a5369 --- /dev/null +++ b/hasura.planx.uk/migrations/1718728257637_populate_team_settings_table/down.sql @@ -0,0 +1,17 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- INSERT INTO team_settings (team_id, reference_code, homepage, help_email, help_phone,help_opening_hours ,email_reply_to_id,has_planning_data , external_planning_site_url,external_planning_site_name,boundary_url,boundary_json) +-- SELECT +-- id as team_id, +-- reference_code, +-- settings ->> 'homepage' as homepage, +-- COALESCE(notify_personalisation ->> 'helpEmail', 'example@council.co.uk') as help_email, +-- COALESCE(notify_personalisation ->> 'helpPhone', '(01234) 567890') as help_phone, +-- COALESCE(notify_personalisation ->> 'helpOpeningHours', 'Monday - Friday, 9am - 5pm') as help_opening_hours, +-- COALESCE(notify_personalisation ->> 'emailReplyToId', '727d48fa-cb8a-42f9-b8b2-55032f3bb451') as email_reply_to_id, +-- CAST(COALESCE(settings ->> 'hasPlanningData', 'false' ) as boolean) as has_planning_data, +-- COALESCE(settings #>> '{externalPlanningSite,url}', 'https://www.planningportal.co.uk/' )as external_planning_site_url, +-- COALESCE(settings #>> '{externalPlanningSite,name}', 'Planning Portal') as external_planning_site_name, +-- settings ->> 'boundary' as boundary_url, +-- boundary as boundary_json +-- FROM teams; diff --git a/hasura.planx.uk/migrations/1718728257637_populate_team_settings_table/up.sql b/hasura.planx.uk/migrations/1718728257637_populate_team_settings_table/up.sql new file mode 100644 index 0000000000..3d7bd93380 --- /dev/null +++ b/hasura.planx.uk/migrations/1718728257637_populate_team_settings_table/up.sql @@ -0,0 +1,15 @@ +INSERT INTO team_settings (team_id, reference_code, homepage, help_email, help_phone,help_opening_hours ,email_reply_to_id,has_planning_data , external_planning_site_url,external_planning_site_name,boundary_url,boundary_json) +SELECT +id as team_id, +reference_code, +settings ->> 'homepage' as homepage, +COALESCE(notify_personalisation ->> 'helpEmail', 'example@council.co.uk') as help_email, +COALESCE(notify_personalisation ->> 'helpPhone', '(01234) 567890') as help_phone, +COALESCE(notify_personalisation ->> 'helpOpeningHours', 'Monday - Friday, 9am - 5pm') as help_opening_hours, +COALESCE(notify_personalisation ->> 'emailReplyToId', '727d48fa-cb8a-42f9-b8b2-55032f3bb451') as email_reply_to_id, +CAST(COALESCE(settings ->> 'hasPlanningData', 'false' ) as boolean) as has_planning_data, +COALESCE(settings #>> '{externalPlanningSite,url}', 'https://www.planningportal.co.uk/' )as external_planning_site_url, +COALESCE(settings #>> '{externalPlanningSite,name}', 'Planning Portal') as external_planning_site_name, +settings ->> 'boundary' as boundary_url, +boundary as boundary_json +FROM teams; From ac99e89d91bb6709d4abfc64526b4c48f04ac95b Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Wed, 19 Jun 2024 09:45:28 +0100 Subject: [PATCH 02/10] add column comments to create table migration --- .../up.sql | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hasura.planx.uk/migrations/1718719894002_create_table_public_team_settings/up.sql b/hasura.planx.uk/migrations/1718719894002_create_table_public_team_settings/up.sql index 00978c3922..e8efc6d33f 100644 --- a/hasura.planx.uk/migrations/1718719894002_create_table_public_team_settings/up.sql +++ b/hasura.planx.uk/migrations/1718719894002_create_table_public_team_settings/up.sql @@ -14,3 +14,12 @@ PRIMARY KEY ("id") , FOREIGN KEY ("team_id") REFERENCES "public"."teams"("id") ON UPDATE cascade ON DELETE cascade, UNIQUE ("id"), UNIQUE ("team_id"), UNIQUE ("reference_code")); COMMENT ON TABLE "public"."team_settings" IS E'Global settings for boundary and contact details'; + +comment on column "public"."team_settings"."reference_code" is E'Team name in three letter short form'; +comment on column "public"."team_settings"."team_id" is E'Linked ID to Teams table'; +comment on column "public"."team_settings"."help_phone" is E'For use in gov notify emails'; +comment on column "public"."team_settings"."help_email" is E'For use in gov notify emails'; +comment on column "public"."team_settings"."help_opening_hours" is E'For use in gov notify emails'; +comment on column "public"."team_settings"."email_reply_to_id" is E'Generate by gov notify and relates to the "reply to" address in notifications'; +comment on column "public"."team_settings"."boundary_url" is E'User entered boundary linked to https://www.planning.data.gov.uk/'; +comment on column "public"."team_settings"."boundary_json" is E'Long form boundary geojson - used to compute boundary__bbox'; From f658e18991970eca6396dbc88c427dc6dc5e3f4b Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Wed, 19 Jun 2024 11:12:02 +0100 Subject: [PATCH 03/10] add seed database scripts and add boundary_url column to create table miigration --- .../up.sql | 3 +- scripts/seed-database/write/team_settings.sql | 69 +++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 scripts/seed-database/write/team_settings.sql diff --git a/hasura.planx.uk/migrations/1718719894002_create_table_public_team_settings/up.sql b/hasura.planx.uk/migrations/1718719894002_create_table_public_team_settings/up.sql index e8efc6d33f..7801459582 100644 --- a/hasura.planx.uk/migrations/1718719894002_create_table_public_team_settings/up.sql +++ b/hasura.planx.uk/migrations/1718719894002_create_table_public_team_settings/up.sql @@ -8,7 +8,8 @@ CREATE TABLE "public"."team_settings" ("id" serial NOT NULL, "email_reply_to_id" text NOT NULL DEFAULT '727d48fa-cb8a-42f9-b8b2-55032f3bb451', "has_planning_data" boolean NOT NULL DEFAULT False, "external_planning_site_url" text DEFAULT 'https://www.planningportal.co.uk/', -"external_planning_site_name" text DEFAULT 'Planning Portal', +"external_planning_site_name" text DEFAULT 'Planning Portal', +"boundary_url" text, "boundary_json" jsonb NOT NULL DEFAULT '{"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [[[1.9134116, 49.528423], [1.9134116, 61.331151], [1.9134116, 61.331151], [-10.76418, 61.331151], [-10.76418, 49.528423]]]}, "properties": {}}'::jsonb, "boundary_url" text, PRIMARY KEY ("id") , FOREIGN KEY ("team_id") REFERENCES "public"."teams"("id") ON UPDATE cascade ON DELETE cascade, diff --git a/scripts/seed-database/write/team_settings.sql b/scripts/seed-database/write/team_settings.sql new file mode 100644 index 0000000000..0a597f1ee5 --- /dev/null +++ b/scripts/seed-database/write/team_settings.sql @@ -0,0 +1,69 @@ +-- 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, + has_planning_data boolean, + external_planning_site_url text, + external_planning_site_name text, + boundary_json jsonb, + boundary_url text +); + +\copy sync_team_settings FROM '/tmp/team_settings.csv' WITH (FORMAT csv, DELIMITER ';'); + +INSERT INTO + team_themes ( + id, + team_id, + reference_code, + homepage, + help_email, + help_phone, + help_opening_hours, + email_reply_to_id, + has_planning_data, + external_planning_site_url, + external_planning_site_name, + boundary_json, + boundary_url + ) +SELECT + id, + team_id, + reference_code, + homepage, + help_email, + help_phone, + help_opening_hours, + email_reply_to_id, + has_planning_data, + external_planning_site_url, + external_planning_site_name, + boundary_json, + boundary_url +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, + has_planning_data = EXCLUDED.has_planning_data, + external_planning_site_url = EXCLUDED.external_planning_site_url, + external_planning_site_name = EXCLUDED.external_planning_site_name, + boundary_json = EXCLUDED.boundary_json, + boundary_url = EXCLUDED.boundary_url; +SELECT + setval('team_settings_id_seq', max(id)) +FROM + team_settings; \ No newline at end of file From b7a1b177f95e4098eebb6da99c45921989f8a346 Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Wed, 19 Jun 2024 11:14:38 +0100 Subject: [PATCH 04/10] add team_settings to container script --- scripts/seed-database/container.sh | 1 + 1 file changed, 1 insertion(+) 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 From 9521799f51593f0fb247ddca3538c818748138de Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Wed, 19 Jun 2024 11:18:46 +0100 Subject: [PATCH 05/10] nit add format to sql up --- .../1718728257637_populate_team_settings_table/up.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hasura.planx.uk/migrations/1718728257637_populate_team_settings_table/up.sql b/hasura.planx.uk/migrations/1718728257637_populate_team_settings_table/up.sql index 3d7bd93380..fb867822dd 100644 --- a/hasura.planx.uk/migrations/1718728257637_populate_team_settings_table/up.sql +++ b/hasura.planx.uk/migrations/1718728257637_populate_team_settings_table/up.sql @@ -8,7 +8,7 @@ COALESCE(notify_personalisation ->> 'helpPhone', '(01234) 567890') as help_phone COALESCE(notify_personalisation ->> 'helpOpeningHours', 'Monday - Friday, 9am - 5pm') as help_opening_hours, COALESCE(notify_personalisation ->> 'emailReplyToId', '727d48fa-cb8a-42f9-b8b2-55032f3bb451') as email_reply_to_id, CAST(COALESCE(settings ->> 'hasPlanningData', 'false' ) as boolean) as has_planning_data, -COALESCE(settings #>> '{externalPlanningSite,url}', 'https://www.planningportal.co.uk/' )as external_planning_site_url, +COALESCE(settings #>> '{externalPlanningSite,url}', 'https://www.planningportal.co.uk/' ) as external_planning_site_url, COALESCE(settings #>> '{externalPlanningSite,name}', 'Planning Portal') as external_planning_site_name, settings ->> 'boundary' as boundary_url, boundary as boundary_json From 6c9c4c01896a00bc646c74ba67ea4b128de7e601 Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Wed, 19 Jun 2024 13:44:04 +0100 Subject: [PATCH 06/10] revert script changes and update team settings permissions --- hasura.planx.uk/metadata/tables.yaml | 14 ++-- scripts/seed-database/container.sh | 1 - scripts/seed-database/write/team_settings.sql | 69 ------------------- 3 files changed, 7 insertions(+), 77 deletions(-) delete mode 100644 scripts/seed-database/write/team_settings.sql diff --git a/hasura.planx.uk/metadata/tables.yaml b/hasura.planx.uk/metadata/tables.yaml index 68c77be20e..5ad72f974f 100644 --- a/hasura.planx.uk/metadata/tables.yaml +++ b/hasura.planx.uk/metadata/tables.yaml @@ -1652,6 +1652,10 @@ - table: name: team_settings schema: public + object_relationships: + - name: team + using: + foreign_key_constraint_on: team_id select_permissions: - role: api permission: @@ -1692,19 +1696,15 @@ - role: public permission: columns: - - has_planning_data - - id - - team_id - boundary_json - boundary_url - - email_reply_to_id - external_planning_site_name - external_planning_site_url - - help_email - - help_opening_hours - - help_phone + - has_planning_data - homepage + - id - reference_code + - team_id filter: {} comment: "" - role: teamEditor diff --git a/scripts/seed-database/container.sh b/scripts/seed-database/container.sh index 03390220ad..a4c369f8cd 100755 --- a/scripts/seed-database/container.sh +++ b/scripts/seed-database/container.sh @@ -26,7 +26,6 @@ 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/team_settings.sql b/scripts/seed-database/write/team_settings.sql deleted file mode 100644 index 0a597f1ee5..0000000000 --- a/scripts/seed-database/write/team_settings.sql +++ /dev/null @@ -1,69 +0,0 @@ --- 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, - has_planning_data boolean, - external_planning_site_url text, - external_planning_site_name text, - boundary_json jsonb, - boundary_url text -); - -\copy sync_team_settings FROM '/tmp/team_settings.csv' WITH (FORMAT csv, DELIMITER ';'); - -INSERT INTO - team_themes ( - id, - team_id, - reference_code, - homepage, - help_email, - help_phone, - help_opening_hours, - email_reply_to_id, - has_planning_data, - external_planning_site_url, - external_planning_site_name, - boundary_json, - boundary_url - ) -SELECT - id, - team_id, - reference_code, - homepage, - help_email, - help_phone, - help_opening_hours, - email_reply_to_id, - has_planning_data, - external_planning_site_url, - external_planning_site_name, - boundary_json, - boundary_url -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, - has_planning_data = EXCLUDED.has_planning_data, - external_planning_site_url = EXCLUDED.external_planning_site_url, - external_planning_site_name = EXCLUDED.external_planning_site_name, - boundary_json = EXCLUDED.boundary_json, - boundary_url = EXCLUDED.boundary_url; -SELECT - setval('team_settings_id_seq', max(id)) -FROM - team_settings; \ No newline at end of file From 084d226fcbe8c4f004f6154088a6b7516d0e3844 Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Wed, 19 Jun 2024 13:46:52 +0100 Subject: [PATCH 07/10] add down sql for population migration --- .../down.sql | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/hasura.planx.uk/migrations/1718728257637_populate_team_settings_table/down.sql b/hasura.planx.uk/migrations/1718728257637_populate_team_settings_table/down.sql index e1621a5369..62c33be674 100644 --- a/hasura.planx.uk/migrations/1718728257637_populate_team_settings_table/down.sql +++ b/hasura.planx.uk/migrations/1718728257637_populate_team_settings_table/down.sql @@ -1,17 +1 @@ --- Could not auto-generate a down migration. --- Please write an appropriate down migration for the SQL below: --- INSERT INTO team_settings (team_id, reference_code, homepage, help_email, help_phone,help_opening_hours ,email_reply_to_id,has_planning_data , external_planning_site_url,external_planning_site_name,boundary_url,boundary_json) --- SELECT --- id as team_id, --- reference_code, --- settings ->> 'homepage' as homepage, --- COALESCE(notify_personalisation ->> 'helpEmail', 'example@council.co.uk') as help_email, --- COALESCE(notify_personalisation ->> 'helpPhone', '(01234) 567890') as help_phone, --- COALESCE(notify_personalisation ->> 'helpOpeningHours', 'Monday - Friday, 9am - 5pm') as help_opening_hours, --- COALESCE(notify_personalisation ->> 'emailReplyToId', '727d48fa-cb8a-42f9-b8b2-55032f3bb451') as email_reply_to_id, --- CAST(COALESCE(settings ->> 'hasPlanningData', 'false' ) as boolean) as has_planning_data, --- COALESCE(settings #>> '{externalPlanningSite,url}', 'https://www.planningportal.co.uk/' )as external_planning_site_url, --- COALESCE(settings #>> '{externalPlanningSite,name}', 'Planning Portal') as external_planning_site_name, --- settings ->> 'boundary' as boundary_url, --- boundary as boundary_json --- FROM teams; +TRUNCATE TABLE "public"."team_settings"; \ No newline at end of file From 1e99aaa278f6b9eb4dd8d0cc454ee0842f410540 Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Wed, 19 Jun 2024 13:49:05 +0100 Subject: [PATCH 08/10] remove typo from boundary_bbox --- .../1718719894002_create_table_public_team_settings/up.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hasura.planx.uk/migrations/1718719894002_create_table_public_team_settings/up.sql b/hasura.planx.uk/migrations/1718719894002_create_table_public_team_settings/up.sql index 7801459582..42df3dfbc7 100644 --- a/hasura.planx.uk/migrations/1718719894002_create_table_public_team_settings/up.sql +++ b/hasura.planx.uk/migrations/1718719894002_create_table_public_team_settings/up.sql @@ -23,4 +23,4 @@ comment on column "public"."team_settings"."help_email" is E'For use in gov noti comment on column "public"."team_settings"."help_opening_hours" is E'For use in gov notify emails'; comment on column "public"."team_settings"."email_reply_to_id" is E'Generate by gov notify and relates to the "reply to" address in notifications'; comment on column "public"."team_settings"."boundary_url" is E'User entered boundary linked to https://www.planning.data.gov.uk/'; -comment on column "public"."team_settings"."boundary_json" is E'Long form boundary geojson - used to compute boundary__bbox'; +comment on column "public"."team_settings"."boundary_json" is E'Long form boundary geojson - used to compute boundary_bbox'; From de68bc5d05ec7613b15bd4b8f024b923a1e51068 Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Wed, 19 Jun 2024 15:48:37 +0100 Subject: [PATCH 09/10] remove extra boundary_url from migration@ --- .../1718719894002_create_table_public_team_settings/up.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hasura.planx.uk/migrations/1718719894002_create_table_public_team_settings/up.sql b/hasura.planx.uk/migrations/1718719894002_create_table_public_team_settings/up.sql index 42df3dfbc7..50faf5931a 100644 --- a/hasura.planx.uk/migrations/1718719894002_create_table_public_team_settings/up.sql +++ b/hasura.planx.uk/migrations/1718719894002_create_table_public_team_settings/up.sql @@ -10,7 +10,7 @@ CREATE TABLE "public"."team_settings" ("id" serial NOT NULL, "external_planning_site_url" text DEFAULT 'https://www.planningportal.co.uk/', "external_planning_site_name" text DEFAULT 'Planning Portal', "boundary_url" text, -"boundary_json" jsonb NOT NULL DEFAULT '{"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [[[1.9134116, 49.528423], [1.9134116, 61.331151], [1.9134116, 61.331151], [-10.76418, 61.331151], [-10.76418, 49.528423]]]}, "properties": {}}'::jsonb, "boundary_url" text, +"boundary_json" jsonb NOT NULL DEFAULT '{"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [[[1.9134116, 49.528423], [1.9134116, 61.331151], [1.9134116, 61.331151], [-10.76418, 61.331151], [-10.76418, 49.528423]]]}, "properties": {}}'::jsonb, PRIMARY KEY ("id") , FOREIGN KEY ("team_id") REFERENCES "public"."teams"("id") ON UPDATE cascade ON DELETE cascade, UNIQUE ("id"), UNIQUE ("team_id"), UNIQUE ("reference_code")); From 4933d0468be833def005eb3e9aa78b1721974ffc Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Thu, 20 Jun 2024 11:42:48 +0100 Subject: [PATCH 10/10] add permissions to team table for teamEditor --- hasura.planx.uk/metadata/tables.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hasura.planx.uk/metadata/tables.yaml b/hasura.planx.uk/metadata/tables.yaml index 5ad72f974f..d96ec6375d 100644 --- a/hasura.planx.uk/metadata/tables.yaml +++ b/hasura.planx.uk/metadata/tables.yaml @@ -1755,7 +1755,14 @@ - help_phone - homepage - reference_code - filter: {} + filter: + team: + members: + _and: + - user_id: + _eq: x-hasura-user-id + - role: + _eq: teamEditor check: null comment: "" - table: