fix(core): Fix migrations on non-public Postgres schema (#3356)

* 🐛 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
This commit is contained in:
Iván Ovejero
2022-05-30 11:33:17 +02:00
committed by GitHub
parent 56c07a45d5
commit b49d493653
18 changed files with 124 additions and 25 deletions

View File

@@ -13,13 +13,21 @@ export class CreateIndexStoppedAt1594828256133 implements MigrationInterface {
tablePrefix = schema + '.' + tablePrefix;
}
await queryRunner.query(`SET search_path TO ${schema};`);
await queryRunner.query(`CREATE INDEX IF NOT EXISTS IDX_${tablePrefixPure}33228da131bb1112247cf52a42 ON ${tablePrefix}execution_entity ("stoppedAt") `);
}
async down(queryRunner: QueryRunner): Promise<void> {
const tablePrefix = config.getEnv('database.tablePrefix');
let tablePrefix = config.getEnv('database.tablePrefix');
await queryRunner.query(`DROP INDEX IDX_${tablePrefix}33228da131bb1112247cf52a42`);
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}33228da131bb1112247cf52a42`);
}
}