2022-11-22 05:11:29 -08:00
|
|
|
import { MigrationInterface, QueryRunner } from 'typeorm';
|
2022-11-09 06:25:00 -08:00
|
|
|
import config from '@/config';
|
2021-01-23 11:00:32 -08:00
|
|
|
|
|
|
|
export class AddWebhookId1611144599516 implements MigrationInterface {
|
|
|
|
name = 'AddWebhookId1611144599516';
|
|
|
|
|
|
|
|
async up(queryRunner: QueryRunner): Promise<void> {
|
2022-04-08 10:37:27 -07:00
|
|
|
let tablePrefix = config.getEnv('database.tablePrefix');
|
2021-01-23 11:00:32 -08:00
|
|
|
const tablePrefixPure = tablePrefix;
|
2022-04-08 10:37:27 -07:00
|
|
|
const schema = config.getEnv('database.postgresdb.schema');
|
2021-01-23 11:00:32 -08:00
|
|
|
if (schema) {
|
|
|
|
tablePrefix = schema + '.' + tablePrefix;
|
|
|
|
}
|
|
|
|
|
2022-05-30 02:33:17 -07:00
|
|
|
await queryRunner.query(`SET search_path TO ${schema};`);
|
|
|
|
|
2022-11-22 05:11:29 -08:00
|
|
|
await queryRunner.query(
|
|
|
|
`ALTER TABLE ${tablePrefix}webhook_entity ADD "webhookId" character varying`,
|
|
|
|
);
|
2021-01-23 11:00:32 -08:00
|
|
|
await queryRunner.query(`ALTER TABLE ${tablePrefix}webhook_entity ADD "pathLength" integer`);
|
2022-11-22 05:11:29 -08:00
|
|
|
await queryRunner.query(
|
|
|
|
`CREATE INDEX IF NOT EXISTS IDX_${tablePrefixPure}16f4436789e804e3e1c9eeb240 ON ${tablePrefix}webhook_entity ("webhookId", "method", "pathLength") `,
|
|
|
|
);
|
2021-01-23 11:00:32 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
async down(queryRunner: QueryRunner): Promise<void> {
|
2022-04-08 10:37:27 -07:00
|
|
|
let tablePrefix = config.getEnv('database.tablePrefix');
|
2021-01-23 11:00:32 -08:00
|
|
|
const tablePrefixPure = tablePrefix;
|
2022-04-08 10:37:27 -07:00
|
|
|
const schema = config.getEnv('database.postgresdb.schema');
|
2021-01-23 11:00:32 -08:00
|
|
|
if (schema) {
|
|
|
|
tablePrefix = schema + '.' + tablePrefix;
|
|
|
|
}
|
2022-05-30 02:33:17 -07:00
|
|
|
await queryRunner.query(`SET search_path TO ${schema};`);
|
2021-01-23 11:00:32 -08:00
|
|
|
|
|
|
|
await queryRunner.query(`DROP INDEX IDX_${tablePrefixPure}16f4436789e804e3e1c9eeb240`);
|
|
|
|
await queryRunner.query(`ALTER TABLE ${tablePrefix}webhook_entity DROP COLUMN "pathLength"`);
|
|
|
|
await queryRunner.query(`ALTER TABLE ${tablePrefix}webhook_entity DROP COLUMN "webhookId"`);
|
|
|
|
}
|
|
|
|
}
|