refactor(core): Add support for implicit schema in postgres migrations (#5233)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-01-24 10:55:20 +01:00
committed by GitHub
parent 726b573eab
commit a86c9a628b
28 changed files with 154 additions and 430 deletions

View File

@@ -1,6 +1,5 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import config from '@/config';
import { runInBatches } from '@db/utils/migrationHelpers';
import { getTablePrefix, runInBatches } from '@db/utils/migrationHelpers';
// replacing the credentials in workflows and execution
// `nodeType: name` changes to `nodeType: { id, name }`
@@ -9,13 +8,7 @@ export class UpdateWorkflowCredentials1630419189837 implements MigrationInterfac
name = 'UpdateWorkflowCredentials1630419189837';
public async up(queryRunner: QueryRunner): Promise<void> {
let tablePrefix = config.getEnv('database.tablePrefix');
const schema = config.getEnv('database.postgresdb.schema');
if (schema) {
tablePrefix = schema + '.' + tablePrefix;
}
await queryRunner.query(`SET search_path TO ${schema};`);
const tablePrefix = getTablePrefix();
const credentialsEntities = await queryRunner.query(`
SELECT id, name, type
@@ -154,12 +147,7 @@ export class UpdateWorkflowCredentials1630419189837 implements MigrationInterfac
}
public async down(queryRunner: QueryRunner): Promise<void> {
let tablePrefix = config.getEnv('database.tablePrefix');
const schema = config.getEnv('database.postgresdb.schema');
if (schema) {
tablePrefix = schema + '.' + tablePrefix;
}
await queryRunner.query(`SET search_path TO ${schema};`);
const tablePrefix = getTablePrefix();
const credentialsEntities = await queryRunner.query(`
SELECT id, name, type