n8n/packages/cli/src/databases/postgresdb/migrations/1589476000887-WebhookModel.ts

32 lines
1.1 KiB
TypeScript
Raw Normal View History

2020-05-30 16:03:58 -07:00
import {
MigrationInterface,
QueryRunner,
} from 'typeorm';
import * as config from '../../../../config';
2020-05-27 16:32:49 -07:00
export class WebhookModel1589476000887 implements MigrationInterface {
name = 'WebhookModel1589476000887';
2020-06-10 06:58:57 -07:00
async up(queryRunner: QueryRunner): Promise<void> {
2020-05-27 16:32:49 -07:00
let tablePrefix = config.get('database.tablePrefix');
2020-06-23 03:43:40 -07:00
const tablePrefixIndex = tablePrefix;
2020-05-27 16:32:49 -07:00
const schema = config.get('database.postgresdb.schema');
if (schema) {
tablePrefix = schema + '.' + tablePrefix;
}
:sparkles: Add support for webhook route parameters (#1343) * :construction: add webhookId to URL * :construction: add webhookId to webhook entity, :wrench: refactor migrations * :construction: :elephant: postgres migration * :construction: add mySQL migration * :construction: refactor mongoDB * :construction: add webhookId to IWebhookDb * :construction: starting workflow with dynamic route works * :zap: production dynamic webhooks complete * :art: fix lint issues * :wrench: dynamic path for webhook-test complete * :art: fix lint issues * :art: fix typescript issue * :zap: add error message for dynamic webhook-test * :hammer: improve handling of leading `/` * :construction: add webhookId to URL * :construction: add webhookId to webhook entity, :wrench: refactor migrations * :construction: :elephant: postgres migration * :construction: add mySQL migration * :construction: refactor mongoDB * :construction: add webhookId to IWebhookDb * :construction: starting workflow with dynamic route works * :zap: production dynamic webhooks complete * :art: fix lint issues * :wrench: dynamic path for webhook-test complete * :art: fix lint issues * :art: fix typescript issue * :zap: add error message for dynamic webhook-test * :hammer: improve handling of leading `/` * :zap: Fix issue that tab-title did not get reset on new workflow * Revert ":zap: Fix issue that tab-title did not get reset on new workflow" This reverts commit 699d0a8946e08339558c72b2714601329fbf5f2c. * :wrench: reset params before extraction * :elephant: removing unique constraint for webhookId * :construction: handle multiple webhooks per id * :wrench: enable webhook-test for multiple WH with same id * :elephant: add migration for postgres * :zap: add mysql migration * :art: fix lint issue Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
2021-01-23 11:00:32 -08:00
await queryRunner.query(`CREATE TABLE IF NOT EXISTS ${tablePrefix}webhook_entity ("workflowId" integer NOT NULL, "webhookPath" character varying NOT NULL, "method" character varying NOT NULL, "node" character varying NOT NULL, CONSTRAINT "PK_${tablePrefixIndex}b21ace2e13596ccd87dc9bf4ea6" PRIMARY KEY ("webhookPath", "method"))`, undefined);
2020-05-27 16:32:49 -07:00
}
2020-06-10 06:58:57 -07:00
async down(queryRunner: QueryRunner): Promise<void> {
2020-05-27 16:32:49 -07:00
let tablePrefix = config.get('database.tablePrefix');
const schema = config.get('database.postgresdb.schema');
if (schema) {
tablePrefix = schema + '.' + tablePrefix;
}
2020-06-10 06:58:57 -07:00
await queryRunner.query(`DROP TABLE ${tablePrefix}webhook_entity`, undefined);
}
2020-05-27 16:32:49 -07:00
}