From 1147bd5407987e8c40b6605b393f66d921653b27 Mon Sep 17 00:00:00 2001 From: danbenton-mojdt <113102670+danbenton-mojdt@users.noreply.github.com> Date: Wed, 31 Jan 2024 11:20:24 +0000 Subject: [PATCH] MAP-635 Add indices to improve performance of SAR queries (#682) --- migrations/20240131000000_form_db.js | 9 +++++++++ migrations/20240131000001_form_db.js | 9 +++++++++ migrations/20240131000002_form_db.js | 13 +++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 migrations/20240131000000_form_db.js create mode 100644 migrations/20240131000001_form_db.js create mode 100644 migrations/20240131000002_form_db.js diff --git a/migrations/20240131000000_form_db.js b/migrations/20240131000000_form_db.js new file mode 100644 index 00000000..6e80dec4 --- /dev/null +++ b/migrations/20240131000000_form_db.js @@ -0,0 +1,9 @@ +exports.up = knex => + knex.schema.table('statement', table => { + table.index('report_id') + }) + +exports.down = knex => + knex.schema.table('statement', table => { + table.dropIndex('report_id') + }) diff --git a/migrations/20240131000001_form_db.js b/migrations/20240131000001_form_db.js new file mode 100644 index 00000000..e453a2f0 --- /dev/null +++ b/migrations/20240131000001_form_db.js @@ -0,0 +1,9 @@ +exports.up = knex => + knex.schema.table('statement_amendments', table => { + table.index('statement_id') + }) + +exports.down = knex => + knex.schema.table('statement_amendments', table => { + table.dropIndex('statement_id') + }) diff --git a/migrations/20240131000002_form_db.js b/migrations/20240131000002_form_db.js new file mode 100644 index 00000000..e36f4dcc --- /dev/null +++ b/migrations/20240131000002_form_db.js @@ -0,0 +1,13 @@ +exports.up = knex => + knex.schema.table('report', table => { + table.index('offender_no') + table.index('created_date') + table.index('incident_date') + }) + +exports.down = knex => + knex.schema.table('report', table => { + table.dropIndex('offender_no') + table.dropIndex('created_date') + table.dropIndex('incident_date') + })