From 1a6ed0f0d9076fed261a6c2669302bf8912f29ff Mon Sep 17 00:00:00 2001 From: Jessica McInchak Date: Mon, 4 Nov 2024 19:10:57 +0100 Subject: [PATCH 1/2] add missing indexes --- hasura.planx.uk/metadata/tables.yaml | 76 +++++++++---------- .../down.sql | 7 ++ .../up.sql | 14 ++++ 3 files changed, 59 insertions(+), 38 deletions(-) create mode 100644 hasura.planx.uk/migrations/1730742914548_create_index_bops_applications_session_id/down.sql create mode 100644 hasura.planx.uk/migrations/1730742914548_create_index_bops_applications_session_id/up.sql diff --git a/hasura.planx.uk/metadata/tables.yaml b/hasura.planx.uk/metadata/tables.yaml index f1b5797f3f..25dafe08a7 100644 --- a/hasura.planx.uk/metadata/tables.yaml +++ b/hasura.planx.uk/metadata/tables.yaml @@ -157,7 +157,7 @@ definition: enable_manual: false insert: - columns: "*" + columns: '*' retry_conf: interval_sec: 30 num_retries: 1 @@ -171,7 +171,7 @@ query_params: type: bops-submission template_engine: Kriti - url: "{{$base_url}}/webhooks/hasura/send-slack-notification" + url: '{{$base_url}}/webhooks/hasura/send-slack-notification' version: 2 - table: name: document_template @@ -225,7 +225,7 @@ definition: enable_manual: false insert: - columns: "*" + columns: '*' retry_conf: interval_sec: 30 num_retries: 1 @@ -239,7 +239,7 @@ query_params: type: email-submission template_engine: Kriti - url: "{{$base_url}}/webhooks/hasura/send-slack-notification" + url: '{{$base_url}}/webhooks/hasura/send-slack-notification' version: 2 - table: name: feedback @@ -483,9 +483,9 @@ forward_client_headers: false headers: - name: authorization - value: "{{HASURA_PLANX_API_KEY}}" + value: '{{HASURA_PLANX_API_KEY}}' timeout: 10 - url: "{{HASURA_PLANX_API_URL}}/webhooks/hasura/validate-input/jsonb/clean-html" + url: '{{HASURA_PLANX_API_URL}}/webhooks/hasura/validate-input/jsonb/clean-html' type: http - role: demoUser permission: @@ -529,9 +529,9 @@ forward_client_headers: false headers: - name: authorization - value: "{{HASURA_PLANX_API_KEY}}" + value: '{{HASURA_PLANX_API_KEY}}' timeout: 10 - url: "{{HASURA_PLANX_API_URL}}/webhooks/hasura/validate-input/jsonb/clean-html" + url: '{{HASURA_PLANX_API_URL}}/webhooks/hasura/validate-input/jsonb/clean-html' type: http - role: teamEditor permission: @@ -562,9 +562,9 @@ forward_client_headers: false headers: - name: authorization - value: "{{HASURA_PLANX_API_KEY}}" + value: '{{HASURA_PLANX_API_KEY}}' timeout: 10 - url: "{{HASURA_PLANX_API_URL}}/webhooks/hasura/validate-input/jsonb/clean-html" + url: '{{HASURA_PLANX_API_URL}}/webhooks/hasura/validate-input/jsonb/clean-html' type: http select_permissions: - role: api @@ -617,7 +617,7 @@ - 1 - 29 - 30 - comment: "For the demo user, we want to ensure they can only see their own flows, and flows from the Open Digital Planning [id = 30], Open Systems Lab [id = 1], and Templates [id = 29] team " + comment: 'For the demo user, we want to ensure they can only see their own flows, and flows from the Open Digital Planning [id = 30], Open Systems Lab [id = 1], and Templates [id = 29] team ' - role: platformAdmin permission: columns: @@ -698,9 +698,9 @@ forward_client_headers: false headers: - name: authorization - value: "{{HASURA_PLANX_API_KEY}}" + value: '{{HASURA_PLANX_API_KEY}}' timeout: 10 - url: "{{HASURA_PLANX_API_URL}}/webhooks/hasura/validate-input/jsonb/clean-html" + url: '{{HASURA_PLANX_API_URL}}/webhooks/hasura/validate-input/jsonb/clean-html' type: http - role: demoUser permission: @@ -740,9 +740,9 @@ forward_client_headers: false headers: - name: authorization - value: "{{HASURA_PLANX_API_KEY}}" + value: '{{HASURA_PLANX_API_KEY}}' timeout: 10 - url: "{{HASURA_PLANX_API_URL}}/webhooks/hasura/validate-input/jsonb/clean-html" + url: '{{HASURA_PLANX_API_URL}}/webhooks/hasura/validate-input/jsonb/clean-html' type: http - role: teamEditor permission: @@ -767,9 +767,9 @@ forward_client_headers: false headers: - name: authorization - value: "{{HASURA_PLANX_API_KEY}}" + value: '{{HASURA_PLANX_API_KEY}}' timeout: 10 - url: "{{HASURA_PLANX_API_URL}}/webhooks/hasura/validate-input/jsonb/clean-html" + url: '{{HASURA_PLANX_API_URL}}/webhooks/hasura/validate-input/jsonb/clean-html' type: http delete_permissions: - role: demoUser @@ -809,9 +809,9 @@ forward_client_headers: false headers: - name: authorization - value: "{{HASURA_PLANX_API_KEY}}" + value: '{{HASURA_PLANX_API_KEY}}' timeout: 10 - url: "{{HASURA_PLANX_API_URL}}/webhooks/hasura/validate-input/jsonb/clean-html" + url: '{{HASURA_PLANX_API_URL}}/webhooks/hasura/validate-input/jsonb/clean-html' type: http select_permissions: - role: demoUser @@ -849,9 +849,9 @@ forward_client_headers: false headers: - name: authorization - value: "{{HASURA_PLANX_API_KEY}}" + value: '{{HASURA_PLANX_API_KEY}}' timeout: 10 - url: "{{HASURA_PLANX_API_URL}}/webhooks/hasura/validate-input/jsonb/clean-html" + url: '{{HASURA_PLANX_API_URL}}/webhooks/hasura/validate-input/jsonb/clean-html' type: http - table: name: lowcal_sessions @@ -998,7 +998,7 @@ method: POST query_params: {} template_engine: Kriti - url: "{{$base_url}}/send-email/confirmation" + url: '{{$base_url}}/send-email/confirmation' version: 2 - name: setup_lowcal_expiry_events definition: @@ -1028,7 +1028,7 @@ method: POST query_params: {} template_engine: Kriti - url: "{{$base_url}}/webhooks/hasura/create-expiry-event" + url: '{{$base_url}}/webhooks/hasura/create-expiry-event' version: 2 - name: setup_lowcal_reminder_events definition: @@ -1058,7 +1058,7 @@ method: POST query_params: {} template_engine: Kriti - url: "{{$base_url}}/webhooks/hasura/create-reminder-event" + url: '{{$base_url}}/webhooks/hasura/create-reminder-event' version: 2 - table: name: operations @@ -1278,7 +1278,7 @@ definition: enable_manual: false insert: - columns: "*" + columns: '*' retry_conf: interval_sec: 10 num_retries: 3 @@ -1300,13 +1300,13 @@ method: POST query_params: {} template_engine: Kriti - url: "{{$base_url}}/webhooks/hasura/create-payment-expiry-events" + url: '{{$base_url}}/webhooks/hasura/create-payment-expiry-events' version: 2 - name: setup_payment_invitation_events definition: enable_manual: false insert: - columns: "*" + columns: '*' retry_conf: interval_sec: 10 num_retries: 3 @@ -1328,13 +1328,13 @@ method: POST query_params: {} template_engine: Kriti - url: "{{$base_url}}/webhooks/hasura/create-payment-invitation-events" + url: '{{$base_url}}/webhooks/hasura/create-payment-invitation-events' version: 2 - name: setup_payment_reminder_events definition: enable_manual: false insert: - columns: "*" + columns: '*' retry_conf: interval_sec: 10 num_retries: 3 @@ -1356,7 +1356,7 @@ method: POST query_params: {} template_engine: Kriti - url: "{{$base_url}}/webhooks/hasura/create-payment-reminder-events" + url: '{{$base_url}}/webhooks/hasura/create-payment-reminder-events' version: 2 - name: setup_payment_send_events definition: @@ -1385,7 +1385,7 @@ method: POST query_params: {} template_engine: Kriti - url: "{{$base_url}}/webhooks/hasura/create-payment-send-events" + url: '{{$base_url}}/webhooks/hasura/create-payment-send-events' version: 2 - table: name: payment_status @@ -1647,12 +1647,12 @@ definition: enable_manual: false insert: - columns: "*" + columns: '*' retry_conf: interval_sec: 30 num_retries: 1 timeout_sec: 60 - webhook: "{{HASURA_PLANX_API_URL}}" + webhook: '{{HASURA_PLANX_API_URL}}' headers: - name: authorization value_from_env: HASURA_PLANX_API_KEY @@ -1661,7 +1661,7 @@ query_params: type: s3-submission template_engine: Kriti - url: "{{$base_url}}/webhooks/hasura/send-slack-notification" + url: '{{$base_url}}/webhooks/hasura/send-slack-notification' version: 2 - table: name: sessions @@ -1804,7 +1804,7 @@ - created_at - submitted_at filter: {} - comment: "For future, if this moves outside of the Flow to somewhere like Team, we should update 'demoUser' to only see submission data related to only their flows. " + comment: 'For future, if this moves outside of the Flow to somewhere like Team, we should update ''demoUser'' to only see submission data related to only their flows. ' - role: platformAdmin permission: columns: @@ -2365,7 +2365,7 @@ - 29 - 30 - 32 - comment: "For the demo user, we want to ensure they can only see their own team [id = 32], and the teams: Open Digital Planning [id = 30], Open Systems Lab [id = 1], and Templates [id = 29] team " + comment: 'For the demo user, we want to ensure they can only see their own team [id = 32], and the teams: Open Digital Planning [id = 30], Open Systems Lab [id = 1], and Templates [id = 29] team ' - role: platformAdmin permission: columns: @@ -2482,7 +2482,7 @@ definition: enable_manual: false insert: - columns: "*" + columns: '*' retry_conf: interval_sec: 30 num_retries: 1 @@ -2496,7 +2496,7 @@ query_params: type: uniform-submission template_engine: Kriti - url: "{{$base_url}}/webhooks/hasura/send-slack-notification" + url: '{{$base_url}}/webhooks/hasura/send-slack-notification' version: 2 - table: name: user_roles diff --git a/hasura.planx.uk/migrations/1730742914548_create_index_bops_applications_session_id/down.sql b/hasura.planx.uk/migrations/1730742914548_create_index_bops_applications_session_id/down.sql new file mode 100644 index 0000000000..f41ebac702 --- /dev/null +++ b/hasura.planx.uk/migrations/1730742914548_create_index_bops_applications_session_id/down.sql @@ -0,0 +1,7 @@ +DROP INDEX IF EXISTS "public"."bops_applications_session_id"; +DROP INDEX IF EXISTS "public"."uniform_applications_session_id_idx"; +DROP INDEX IF EXISTS "public"."email_applications_session_id_idx"; +DROP INDEX IF EXISTS "public"."s3_applications_session_id_idx"; +DROP INDEX IF EXISTS "public"."feedback_flow_id_team_id_idx"; +DROP INDEX IF EXISTS "public"."reconciliation_requests_session_id_idx"; +DROP INDEX IF EXISTS "public"."published_flows_created_at_idx"; diff --git a/hasura.planx.uk/migrations/1730742914548_create_index_bops_applications_session_id/up.sql b/hasura.planx.uk/migrations/1730742914548_create_index_bops_applications_session_id/up.sql new file mode 100644 index 0000000000..a2d5099a67 --- /dev/null +++ b/hasura.planx.uk/migrations/1730742914548_create_index_bops_applications_session_id/up.sql @@ -0,0 +1,14 @@ +CREATE INDEX "bops_applications_session_id_idx" on + "public"."bops_applications" using hash ("session_id"); +CREATE INDEX "uniform_applications_session_id_idx" on + "public"."uniform_applications" using hash ("submission_reference"); +CREATE INDEX "email_applications_session_id_idx" on + "public"."email_applications" using hash ("session_id"); +CREATE INDEX "s3_applications_session_id_idx" on + "public"."s3_applications" using hash ("session_id"); +CREATE INDEX "feedback_flow_id_team_id_idx" on + "public"."feedback" using btree ("team_id", "flow_id"); +CREATE INDEX "reconciliation_requests_session_id_idx" on + "public"."reconciliation_requests" using hash ("session_id"); +CREATE INDEX "published_flows_created_at_idx" on + "public"."published_flows" using btree ("created_at"); From e40a3d1079a35ef35743f14bd7cf1ec7c19950e3 Mon Sep 17 00:00:00 2001 From: Jessica McInchak Date: Tue, 5 Nov 2024 09:17:46 +0100 Subject: [PATCH 2/2] add DESC order to published flows date index --- .../up.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hasura.planx.uk/migrations/1730742914548_create_index_bops_applications_session_id/up.sql b/hasura.planx.uk/migrations/1730742914548_create_index_bops_applications_session_id/up.sql index a2d5099a67..61b2af6eca 100644 --- a/hasura.planx.uk/migrations/1730742914548_create_index_bops_applications_session_id/up.sql +++ b/hasura.planx.uk/migrations/1730742914548_create_index_bops_applications_session_id/up.sql @@ -11,4 +11,4 @@ CREATE INDEX "feedback_flow_id_team_id_idx" on CREATE INDEX "reconciliation_requests_session_id_idx" on "public"."reconciliation_requests" using hash ("session_id"); CREATE INDEX "published_flows_created_at_idx" on - "public"."published_flows" using btree ("created_at"); + "public"."published_flows" using btree ("created_at" DESC NULLS LAST);