Fix migration search path (#6520)

This commit is contained in:
Weiko
2024-08-02 21:34:20 +02:00
committed by GitHub
parent 1f5c25ac0a
commit 9cf08d912a
2 changed files with 3 additions and 4 deletions

View File

@ -688,7 +688,7 @@ export class WorkspaceQueryRunnerService {
return await workspaceDataSource?.transaction( return await workspaceDataSource?.transaction(
async (transactionManager) => { async (transactionManager) => {
await transactionManager.query(` await transactionManager.query(`
SET search_path TO ${this.workspaceDataSourceService.getSchemaName( SET LOCAL search_path TO ${this.workspaceDataSourceService.getSchemaName(
workspaceId, workspaceId,
)}; )};
`); `);

View File

@ -74,12 +74,11 @@ export class WorkspaceMigrationRunnerService {
await queryRunner.connect(); await queryRunner.connect();
await queryRunner.startTransaction(); await queryRunner.startTransaction();
// Reset search_path to force to postgres to prefix migrations in the correct schema due to postgres driver behavior
await queryRunner.query('SET search_path TO public');
const schemaName = const schemaName =
this.workspaceDataSourceService.getSchemaName(workspaceId); this.workspaceDataSourceService.getSchemaName(workspaceId);
await queryRunner.query(`SET LOCAL search_path TO ${schemaName}`);
try { try {
// Loop over each migration and create or update the table // Loop over each migration and create or update the table
for (const migration of flattenedPendingMigrations) { for (const migration of flattenedPendingMigrations) {