From 17c0d7137fb884e34ccc54fb706a5a7af470d10a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20G=C3=B3is?= Date: Tue, 20 Feb 2024 15:45:33 +0000 Subject: [PATCH] chore: add action state db indexes (#6283) Adds some relevant indexes to `action_states`, useful for our new "action events" query. --- ...20240220130622-add-action-state-indexes.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/migrations/20240220130622-add-action-state-indexes.js diff --git a/src/migrations/20240220130622-add-action-state-indexes.js b/src/migrations/20240220130622-add-action-state-indexes.js new file mode 100644 index 0000000000..f2007fb6fc --- /dev/null +++ b/src/migrations/20240220130622-add-action-state-indexes.js @@ -0,0 +1,21 @@ +exports.up = function (db, cb) { + db.runSql( + ` + CREATE INDEX IF NOT EXISTS idx_action_states_action_id ON action_states(action_id); + CREATE INDEX IF NOT EXISTS idx_action_states_observable_event_id ON action_states(observable_event_id); + CREATE INDEX IF NOT EXISTS idx_action_states_action_observable ON action_states(action_id, observable_event_id); + `, + cb, + ); +}; + +exports.down = function (db, cb) { + db.runSql( + ` + DROP INDEX IF EXISTS idx_action_states_action_id; + DROP INDEX IF EXISTS idx_action_states_observable_event_id; + DROP INDEX IF EXISTS idx_action_states_action_observable; + `, + cb, + ); +};