From 491854740f633c41052d09ee94e29bc8d07a75de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gast=C3=B3n=20Fournier?= Date: Thu, 11 Jan 2024 13:18:56 +0100 Subject: [PATCH 1/2] feat: add automated actions tables --- .../20240111125100-automated-actions.js | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/migrations/20240111125100-automated-actions.js diff --git a/src/migrations/20240111125100-automated-actions.js b/src/migrations/20240111125100-automated-actions.js new file mode 100644 index 000000000000..b8064a4649bd --- /dev/null +++ b/src/migrations/20240111125100-automated-actions.js @@ -0,0 +1,43 @@ +exports.up = function (db, cb) { + db.runSql( + ` + CREATE TABLE IF NOT EXISTS action_sets + ( + id SERIAL PRIMARY KEY NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + created_by_user_id INTEGER, + name varchar(255), + actor_id INTEGER, + source varchar(255), + source_id INTEGER, + payload JSONB DEFAULT '{}'::jsonb NOT NULL, + FOREIGN KEY (project) references projects(id) ON DELETE CASCADE, + ); + + CREATE TABLE IF NOT EXISTS actions + ( + id SERIAL PRIMARY KEY NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + created_by_user_id INTEGER, + action_set_id INTEGER references action_sets (id) ON DELETE CASCADE, + sort_order INTEGER, + action varchar(255) NOT NULL, + execution_params JSONB DEFAULT '{}'::jsonb NOT NULL, + ); + + CREATE INDEX idx_action_sets_project ON action_sets (project); + `, + cb, + ); +}; + +exports.down = function (db, cb) { + db.runSql( + ` + DROP INDEX IF EXISTS idx_action_sets_project; + DROP TABLE IF EXISTS actions; + DROP TABLE IF EXISTS action_sets; + `, + cb, + ); +}; From 5b99a6e4e4168e8768a8b4d5fc01c43fb2707d01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gast=C3=B3n=20Fournier?= Date: Thu, 11 Jan 2024 14:15:07 +0100 Subject: [PATCH 2/2] fix: migrations --- src/migrations/20240111125100-automated-actions.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/migrations/20240111125100-automated-actions.js b/src/migrations/20240111125100-automated-actions.js index b8064a4649bd..ab7519416d14 100644 --- a/src/migrations/20240111125100-automated-actions.js +++ b/src/migrations/20240111125100-automated-actions.js @@ -7,11 +7,12 @@ exports.up = function (db, cb) { created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), created_by_user_id INTEGER, name varchar(255), + project VARCHAR(255) NOT NULL, actor_id INTEGER, source varchar(255), source_id INTEGER, payload JSONB DEFAULT '{}'::jsonb NOT NULL, - FOREIGN KEY (project) references projects(id) ON DELETE CASCADE, + FOREIGN KEY (project) references projects(id) ON DELETE CASCADE ); CREATE TABLE IF NOT EXISTS actions @@ -22,7 +23,7 @@ exports.up = function (db, cb) { action_set_id INTEGER references action_sets (id) ON DELETE CASCADE, sort_order INTEGER, action varchar(255) NOT NULL, - execution_params JSONB DEFAULT '{}'::jsonb NOT NULL, + execution_params JSONB DEFAULT '{}'::jsonb NOT NULL ); CREATE INDEX idx_action_sets_project ON action_sets (project);