The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Fix migration search path (#6520)
Weiko9cf08d912a1d
diff --git a/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-runner.service.ts b/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-runner.service.tsindex bef145c1e2c..fc70c7c8451 100644--- a/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-runner.service.ts+++ b/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-runner.service.ts@@ -688,7 +688,7 @@ export class WorkspaceQueryRunnerService {return await workspaceDataSource?.transaction(async (transactionManager) => {await transactionManager.query(`- SET search_path TO ${this.workspaceDataSourceService.getSchemaName(+ SET LOCAL search_path TO ${this.workspaceDataSourceService.getSchemaName(workspaceId,)};`);diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-migration-runner/workspace-migration-runner.service.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-migration-runner/workspace-migration-runner.service.tsindex bd5a78ee193..00727eababb 100644--- a/packages/twenty-server/src/engine/workspace-manager/workspace-migration-runner/workspace-migration-runner.service.ts+++ b/packages/twenty-server/src/engine/workspace-manager/workspace-migration-runner/workspace-migration-runner.service.ts@@ -74,12 +74,11 @@ export class WorkspaceMigrationRunnerService {await queryRunner.connect();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 =this.workspaceDataSourceService.getSchemaName(workspaceId);+ await queryRunner.query(`SET LOCAL search_path TO ${schemaName}`);+try {// Loop over each migration and create or update the tablefor (const migration of flattenedPendingMigrations) {