Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: incoming webhooks and tokens migration #5670

Merged
merged 3 commits into from
Dec 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions src/migrations/20231215105713-incoming-webhooks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
exports.up = function (db, cb) {
db.runSql(
`
CREATE TABLE IF NOT EXISTS incoming_webhooks
(
id SERIAL PRIMARY KEY NOT NULL,
enabled BOOLEAN DEFAULT true NOT NULL,
name TEXT NOT NULL,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
created_by_user_id INTEGER NOT NULL
);
CREATE INDEX incoming_webhooks_enabled_idx ON incoming_webhooks(enabled);

CREATE TABLE IF NOT EXISTS incoming_webhook_tokens
(
id SERIAL PRIMARY KEY NOT NULL,
secret TEXT NOT NULL,
name TEXT NOT NULL,
incoming_webhook_id INTEGER NOT NULL REFERENCES incoming_webhooks(id) ON DELETE CASCADE,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
created_by_user_id INTEGER NOT NULL
);
CREATE INDEX incoming_webhook_tokens_webhook_id_idx ON incoming_webhook_tokens(incoming_webhook_id);
`,
cb,
);
};

exports.down = function (db, cb) {
db.runSql(
`
DROP INDEX IF EXISTS incoming_webhooks_enabled_idx;
DROP INDEX IF EXISTS incoming_webhook_tokens_webhook_id_idx;
DROP TABLE IF EXISTS incoming_webhook_tokens;
DROP TABLE IF EXISTS incoming_webhooks;
`,
cb,
);
};