refactor(core): Add support for implicit schema in postgres migrations (#5233)
This commit is contained in:
committed by
GitHub
parent
726b573eab
commit
a86c9a628b
@@ -1,6 +1,5 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
import { logMigrationEnd, logMigrationStart } from '@db/utils/migrationHelpers';
|
||||
import config from '@/config';
|
||||
import { getTablePrefix, logMigrationEnd, logMigrationStart } from '@db/utils/migrationHelpers';
|
||||
|
||||
export class IntroducePinData1654090467022 implements MigrationInterface {
|
||||
name = 'IntroducePinData1654090467022';
|
||||
@@ -8,26 +7,14 @@ export class IntroducePinData1654090467022 implements MigrationInterface {
|
||||
async up(queryRunner: QueryRunner) {
|
||||
logMigrationStart(this.name);
|
||||
|
||||
const schema = config.getEnv('database.postgresdb.schema');
|
||||
const tablePrefix = config.getEnv('database.tablePrefix');
|
||||
|
||||
await queryRunner.query(`SET search_path TO ${schema}`);
|
||||
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE ${schema}.${tablePrefix}workflow_entity ADD "pinData" json`,
|
||||
);
|
||||
const tablePrefix = getTablePrefix();
|
||||
await queryRunner.query(`ALTER TABLE ${tablePrefix}workflow_entity ADD "pinData" json`);
|
||||
|
||||
logMigrationEnd(this.name);
|
||||
}
|
||||
|
||||
async down(queryRunner: QueryRunner) {
|
||||
const schema = config.getEnv('database.postgresdb.schema');
|
||||
const tablePrefix = config.getEnv('database.tablePrefix');
|
||||
|
||||
await queryRunner.query(`SET search_path TO ${schema}`);
|
||||
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE ${schema}.${tablePrefix}workflow_entity DROP COLUMN "pinData"`,
|
||||
);
|
||||
const tablePrefix = getTablePrefix();
|
||||
await queryRunner.query(`ALTER TABLE ${tablePrefix}workflow_entity DROP COLUMN "pinData"`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user