From 2b46c89fac2ec0b3340cb4a11e6c19ea40d5b6b1 Mon Sep 17 00:00:00 2001 From: Aditya Sridhar Date: Tue, 12 Sep 2023 17:01:18 -0400 Subject: [PATCH 1/3] fix: opp-status indexing --- ...2195046_add-grants-opportunity-status-index.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 packages/server/migrations/20230912195046_add-grants-opportunity-status-index.js diff --git a/packages/server/migrations/20230912195046_add-grants-opportunity-status-index.js b/packages/server/migrations/20230912195046_add-grants-opportunity-status-index.js new file mode 100644 index 000000000..88697c1a2 --- /dev/null +++ b/packages/server/migrations/20230912195046_add-grants-opportunity-status-index.js @@ -0,0 +1,15 @@ +/** + * @param { import("knex").Knex } knex + * @returns { Promise } + */ +exports.up = function (knex) { + return knex.raw('CREATE INDEX IF NOT EXISTS idx_grants_opportunity_status ON grants USING hash (opportunity_status);'); +}; + +/** + * @param { import("knex").Knex } knex + * @returns { Promise } + */ +exports.down = function (knex) { + return knex.raw('DROP INDEX IF EXISTS idx_grants_opportunity_status;'); +}; From adac685c8300abd93cfa97b853814e871133691d Mon Sep 17 00:00:00 2001 From: Aditya Sridhar Date: Tue, 12 Sep 2023 19:45:44 -0400 Subject: [PATCH 2/3] fix: changes to btree partial index --- .../20230912195046_add-grants-opportunity-status-index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/migrations/20230912195046_add-grants-opportunity-status-index.js b/packages/server/migrations/20230912195046_add-grants-opportunity-status-index.js index 88697c1a2..52dae8457 100644 --- a/packages/server/migrations/20230912195046_add-grants-opportunity-status-index.js +++ b/packages/server/migrations/20230912195046_add-grants-opportunity-status-index.js @@ -3,7 +3,7 @@ * @returns { Promise } */ exports.up = function (knex) { - return knex.raw('CREATE INDEX IF NOT EXISTS idx_grants_opportunity_status ON grants USING hash (opportunity_status);'); + return knex.raw(`CREATE INDEX IF NOT EXISTS idx_grants_opportunity_status ON grants USING btree (opportunity_status) WHERE (opportunity_status <> 'archived'::text)`); }; /** From 5eadfd9becfb309d7ad1cd603dba0ded877e60f9 Mon Sep 17 00:00:00 2001 From: aditya Date: Wed, 13 Sep 2023 08:58:13 -0400 Subject: [PATCH 3/3] Remove semicolon Co-authored-by: Tyler Hendrickson --- .../20230912195046_add-grants-opportunity-status-index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/migrations/20230912195046_add-grants-opportunity-status-index.js b/packages/server/migrations/20230912195046_add-grants-opportunity-status-index.js index 52dae8457..484bbebc1 100644 --- a/packages/server/migrations/20230912195046_add-grants-opportunity-status-index.js +++ b/packages/server/migrations/20230912195046_add-grants-opportunity-status-index.js @@ -11,5 +11,5 @@ exports.up = function (knex) { * @returns { Promise } */ exports.down = function (knex) { - return knex.raw('DROP INDEX IF EXISTS idx_grants_opportunity_status;'); + return knex.raw('DROP INDEX IF EXISTS idx_grants_opportunity_status'); };