mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
* ⚡ Set path alias for config * ⚡ Update config export * ⚡ Simplify config imports * ⚡ Update also additional imports * ⚡ Update path in collation migration * ⚡ Resolve aliased paths * 👕 Fix Codacy issue * 👕 Retry to fix Codacy issue Co-authored-by: Jan <janober@users.noreply.github.com> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
27 lines
1.9 KiB
TypeScript
27 lines
1.9 KiB
TypeScript
import {MigrationInterface, QueryRunner} from "typeorm";
|
|
import { config } from '@config';
|
|
|
|
export class AddWebhookId1611071044839 implements MigrationInterface {
|
|
name = 'AddWebhookId1611071044839';
|
|
|
|
async up(queryRunner: QueryRunner): Promise<void> {
|
|
const tablePrefix = config.get('database.tablePrefix');
|
|
|
|
await queryRunner.query(`CREATE TABLE "temporary_webhook_entity" ("workflowId" integer NOT NULL, "webhookPath" varchar NOT NULL, "method" varchar NOT NULL, "node" varchar NOT NULL, "webhookId" varchar, "pathLength" integer, PRIMARY KEY ("webhookPath", "method"))`);
|
|
await queryRunner.query(`INSERT INTO "temporary_webhook_entity"("workflowId", "webhookPath", "method", "node") SELECT "workflowId", "webhookPath", "method", "node" FROM "${tablePrefix}webhook_entity"`);
|
|
await queryRunner.query(`DROP TABLE "${tablePrefix}webhook_entity"`);
|
|
await queryRunner.query(`ALTER TABLE "temporary_webhook_entity" RENAME TO "${tablePrefix}webhook_entity"`);
|
|
await queryRunner.query(`CREATE INDEX "IDX_${tablePrefix}742496f199721a057051acf4c2" ON "${tablePrefix}webhook_entity" ("webhookId", "method", "pathLength") `);
|
|
}
|
|
|
|
async down(queryRunner: QueryRunner): Promise<void> {
|
|
const tablePrefix = config.get('database.tablePrefix');
|
|
|
|
await queryRunner.query(`DROP INDEX "IDX_${tablePrefix}742496f199721a057051acf4c2"`);
|
|
await queryRunner.query(`ALTER TABLE "${tablePrefix}webhook_entity" RENAME TO "temporary_webhook_entity"`);
|
|
await queryRunner.query(`CREATE TABLE "${tablePrefix}webhook_entity" ("workflowId" integer NOT NULL, "webhookPath" varchar NOT NULL, "method" varchar NOT NULL, "node" varchar NOT NULL, PRIMARY KEY ("webhookPath", "method"))`);
|
|
await queryRunner.query(`INSERT INTO "${tablePrefix}webhook_entity"("workflowId", "webhookPath", "method", "node") SELECT "workflowId", "webhookPath", "method", "node" FROM "temporary_webhook_entity"`);
|
|
await queryRunner.query(`DROP TABLE "temporary_webhook_entity"`);
|
|
}
|
|
}
|