fase(16): integrations module
This commit is contained in:
44
dist/db/migrations/006_integrations_tables.js
vendored
Normal file
44
dist/db/migrations/006_integrations_tables.js
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.up = up;
|
||||
exports.down = down;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
async function up(db) {
|
||||
await db.schema
|
||||
.createTable('integrations')
|
||||
.ifNotExists()
|
||||
.addColumn('id', 'text', (col) => col.primaryKey())
|
||||
.addColumn('name', 'text', (col) => col.notNull())
|
||||
.addColumn('type', 'text', (col) => col.notNull())
|
||||
.addColumn('enabled', 'integer', (col) => col.notNull().defaultTo(1))
|
||||
.addColumn('config_json', 'text', (col) => col.notNull().defaultTo('{}'))
|
||||
.addColumn('created_at', 'integer', (col) => col.notNull())
|
||||
.execute();
|
||||
await db.schema
|
||||
.createTable('webhook_endpoints')
|
||||
.ifNotExists()
|
||||
.addColumn('id', 'text', (col) => col.primaryKey())
|
||||
.addColumn('url', 'text', (col) => col.notNull())
|
||||
.addColumn('secret', 'text', (col) => col.notNull())
|
||||
.addColumn('enabled', 'integer', (col) => col.notNull().defaultTo(1))
|
||||
.addColumn('created_at', 'integer', (col) => col.notNull())
|
||||
.addColumn('last_delivered_at', 'integer')
|
||||
.addColumn('last_status', 'integer')
|
||||
.execute();
|
||||
await db.schema
|
||||
.createTable('webhook_deliveries')
|
||||
.ifNotExists()
|
||||
.addColumn('id', 'text', (col) => col.primaryKey())
|
||||
.addColumn('endpoint_id', 'text', (col) => col.notNull())
|
||||
.addColumn('event', 'text', (col) => col.notNull())
|
||||
.addColumn('payload_json', 'text', (col) => col.notNull())
|
||||
.addColumn('status', 'integer', (col) => col.notNull())
|
||||
.addColumn('attempted_at', 'integer', (col) => col.notNull())
|
||||
.execute();
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
async function down(db) {
|
||||
await db.schema.dropTable('webhook_deliveries').ifExists().execute();
|
||||
await db.schema.dropTable('webhook_endpoints').ifExists().execute();
|
||||
await db.schema.dropTable('integrations').ifExists().execute();
|
||||
}
|
||||
Reference in New Issue
Block a user