* 🐛 Fix UM migration * ⚡ Account for schema in `search_path` * 🔥 Remove unneeded schema refs * 🧪 Account for alt schema in DB testing * ⚡ Add schema to `IncreaseTypeVarcharLimit` * ⚡ Set `search_path` in every migration * ⚡ Set `search_path` in down migrations
37 lines
1.5 KiB
TypeScript
37 lines
1.5 KiB
TypeScript
import {MigrationInterface, QueryRunner} from "typeorm";
|
|
import * as config from '../../../../config';
|
|
|
|
export class AddWebhookId1611144599516 implements MigrationInterface {
|
|
name = 'AddWebhookId1611144599516';
|
|
|
|
async up(queryRunner: QueryRunner): Promise<void> {
|
|
let tablePrefix = config.getEnv('database.tablePrefix');
|
|
const tablePrefixPure = tablePrefix;
|
|
const schema = config.getEnv('database.postgresdb.schema');
|
|
if (schema) {
|
|
tablePrefix = schema + '.' + tablePrefix;
|
|
}
|
|
|
|
await queryRunner.query(`SET search_path TO ${schema};`);
|
|
|
|
await queryRunner.query(`ALTER TABLE ${tablePrefix}webhook_entity ADD "webhookId" character varying`);
|
|
await queryRunner.query(`ALTER TABLE ${tablePrefix}webhook_entity ADD "pathLength" integer`);
|
|
await queryRunner.query(`CREATE INDEX IF NOT EXISTS IDX_${tablePrefixPure}16f4436789e804e3e1c9eeb240 ON ${tablePrefix}webhook_entity ("webhookId", "method", "pathLength") `);
|
|
}
|
|
|
|
async down(queryRunner: QueryRunner): Promise<void> {
|
|
let tablePrefix = config.getEnv('database.tablePrefix');
|
|
const tablePrefixPure = tablePrefix;
|
|
const schema = config.getEnv('database.postgresdb.schema');
|
|
if (schema) {
|
|
tablePrefix = schema + '.' + tablePrefix;
|
|
}
|
|
await queryRunner.query(`SET search_path TO ${schema};`);
|
|
|
|
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"`);
|
|
}
|
|
|
|
}
|