Skip to content

Commit

Permalink
chore: action_set_events db table migration (#6298)
Browse files Browse the repository at this point in the history
https://linear.app/unleash/issue/2-1962/implement-new-action-events-logic

Adds a new `action_set_events` table for the new action events logic.

Even though observable events are technically immutable, we're storing
the observable event along with the action set event. This allows us to
avoid 1 join while allowing us to persist action set event information
after deleting observable events, if we wish to do so at a later stage.
  • Loading branch information
nunogois authored Feb 21, 2024
1 parent 0ccfc29 commit 4a4d538
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/migrations/20240221082758-action-events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
exports.up = function (db, cb) {
db.runSql(
`
CREATE TABLE IF NOT EXISTS action_set_events
(
id SERIAL PRIMARY KEY NOT NULL,
action_set_id INTEGER NOT NULL,
observable_event_id INTEGER NOT NULL,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
state TEXT NOT NULL,
observable_event JSONB NOT NULL,
action_set JSONB NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_action_set_events_observable_event_id ON action_set_events(observable_event_id);
CREATE INDEX IF NOT EXISTS idx_action_set_events_action_set_id_state ON action_set_events(action_set_id, state);
`,
cb,
);
};

exports.down = function (db, cb) {
db.runSql(
`
DROP INDEX IF EXISTS idx_action_set_events_observable_event_id;
DROP INDEX IF EXISTS idx_action_set_events_action_set_id_state;
DROP TABLE IF EXISTS action_set_events;
`,
cb,
);
};

0 comments on commit 4a4d538

Please sign in to comment.