From 8ba5cdced1d92d0a707f38badf38a992941e161a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gast=C3=B3n=20Fournier?= Date: Mon, 22 Jan 2024 11:49:35 +0100 Subject: [PATCH] feat: add action states (#5983) ## About the changes Add action states table without an index yet --- .../20240119171200-action-states.js | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/migrations/20240119171200-action-states.js diff --git a/src/migrations/20240119171200-action-states.js b/src/migrations/20240119171200-action-states.js new file mode 100644 index 0000000000..366c3d57f0 --- /dev/null +++ b/src/migrations/20240119171200-action-states.js @@ -0,0 +1,28 @@ +exports.up = function (db, cb) { + db.runSql( + ` + CREATE TABLE IF NOT EXISTS action_states + ( + id SERIAL PRIMARY KEY NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + state VARCHAR(255) NOT NULL, + details VARCHAR(255), + action_id INTEGER NOT NULL, + observable_event_id INTEGER NOT NULL, + FOREIGN KEY (observable_event_id) references observable_events(id), + FOREIGN KEY (action_id) references actions(id) + ); + `, + cb, + ); +}; + +exports.down = function (db, cb) { + db.runSql( + ` + DROP INDEX IF EXISTS idx_state_to_observable_event_id; + DROP TABLE IF EXISTS action_states; + `, + cb, + ); +};