Skip to content

The open alternative to Salesforce, designed for AI.

Invalidate and flush cache post 1.16 upgrade (#17465)

Paul Rastoin16826224cd3d
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/1-16/1-16-flush-v2-cache-and-increment-metadata-version.command.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/1-16/1-16-flush-v2-cache-and-increment-metadata-version.command.ts
new file mode 100644
index 00000000000..f579badc4fb
--- /dev/null
+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/1-16/1-16-flush-v2-cache-and-increment-metadata-version.command.ts
@@ -0,0 +1,54 @@
+import { InjectRepository } from '@nestjs/typeorm';
+
+import { Command } from 'nest-commander';
+import { Repository } from 'typeorm';
+
+import { ActiveOrSuspendedWorkspacesMigrationCommandRunner } from 'src/database/commands/command-runners/active-or-suspended-workspaces-migration.command-runner';
+import { RunOnWorkspaceArgs } from 'src/database/commands/command-runners/workspaces-migration.command-runner';
+import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
+import { DataSourceService } from 'src/engine/metadata-modules/data-source/data-source.service';
+import { ALL_FLAT_ENTITY_MAPS_PROPERTIES } from 'src/engine/metadata-modules/flat-entity/constant/all-flat-entity-maps-properties.constant';
+import { GlobalWorkspaceOrmManager } from 'src/engine/twenty-orm/global-workspace-datasource/global-workspace-orm.manager';
+import { WorkspaceMigrationRunnerService } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-runner/services/workspace-migration-runner.service';
+
+@Command({
+ name: 'upgrade:1-16:flush-v2-cache-and-increment-metadata-version',
+ description: 'Flush the whole v2 cache and increment the metadata version',
+})
+export class FlushV2CacheAndIncrementMetadataVersionCommand extends ActiveOrSuspendedWorkspacesMigrationCommandRunner {
+ constructor(
+ @InjectRepository(WorkspaceEntity)
+ protected readonly workspaceRepository: Repository<WorkspaceEntity>,
+ protected readonly globalWorkspaceOrmManager: GlobalWorkspaceOrmManager,
+ protected readonly dataSourceService: DataSourceService,
+ private readonly workspaceMigrationRunnerService: WorkspaceMigrationRunnerService,
+ ) {
+ super(workspaceRepository, globalWorkspaceOrmManager, dataSourceService);
+ }
+
+ override async runOnWorkspace({
+ workspaceId,
+ options,
+ }: RunOnWorkspaceArgs): Promise<void> {
+ this.logger.log(
+ `Flushing v2 cache and incrementing metadata version for workspace ${workspaceId}`,
+ );
+
+ if (options.dryRun) {
+ this.logger.log(
+ `DRY RUN: Would flush v2 cache and increment metadata version for workspace ${workspaceId}`,
+ );
+
+ return;
+ }
+
+ await this.workspaceMigrationRunnerService.invalidateCache({
+ allFlatEntityMapsKeys: ALL_FLAT_ENTITY_MAPS_PROPERTIES,
+ workspaceId,
+ });
+
+ this.logger.log(
+ `Successfully flushed v2 cache and incremented metadata version for workspace ${workspaceId}`,
+ );
+ }
+}
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/1-16/1-16-upgrade-version-command.module.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/1-16/1-16-upgrade-version-command.module.ts
index 17d3dd23d83..8ff081c9d1c 100644
--- a/packages/twenty-server/src/database/commands/upgrade-version-command/1-16/1-16-upgrade-version-command.module.ts
+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/1-16/1-16-upgrade-version-command.module.ts
@@ -3,10 +3,12 @@ import { TypeOrmModule } from '@nestjs/typeorm';
import { BackfillOpportunityOwnerFieldCommand } from 'src/database/commands/upgrade-version-command/1-16/1-16-backfill-opportunity-owner-field.command';
import { BackfillStandardPageLayoutsCommand } from 'src/database/commands/upgrade-version-command/1-16/1-16-backfill-standard-page-layouts.command';
+import { FlushV2CacheAndIncrementMetadataVersionCommand } from 'src/database/commands/upgrade-version-command/1-16/1-16-flush-v2-cache-and-increment-metadata-version.command';
import { IdentifyAgentMetadataCommand } from 'src/database/commands/upgrade-version-command/1-16/1-16-identify-agent-metadata.command';
import { IdentifyFieldMetadataCommand } from 'src/database/commands/upgrade-version-command/1-16/1-16-identify-field-metadata.command';
import { IdentifyIndexMetadataCommand } from 'src/database/commands/upgrade-version-command/1-16/1-16-identify-index-metadata.command';
import { IdentifyObjectMetadataCommand } from 'src/database/commands/upgrade-version-command/1-16/1-16-identify-object-metadata.command';
+import { IdentifyRemainingEntitiesMetadataCommand } from 'src/database/commands/upgrade-version-command/1-16/1-16-identify-remaining-entities-metadata.command';
import { IdentifyRoleMetadataCommand } from 'src/database/commands/upgrade-version-command/1-16/1-16-identify-role-metadata.command';
import { IdentifyViewFieldMetadataCommand } from 'src/database/commands/upgrade-version-command/1-16/1-16-identify-view-field-metadata.command';
import { IdentifyViewFilterMetadataCommand } from 'src/database/commands/upgrade-version-command/1-16/1-16-identify-view-filter-metadata.command';
@@ -16,7 +18,6 @@ import { MakeAgentUniversalIdentifierAndApplicationIdNotNullableMigrationCommand
import { MakeFieldMetadataUniversalIdentifierAndApplicationIdNotNullableMigrationCommand } from 'src/database/commands/upgrade-version-command/1-16/1-16-make-field-metadata-universal-identifier-and-application-id-not-nullable-migration.command';
import { MakeIndexMetadataUniversalIdentifierAndApplicationIdNotNullableMigrationCommand } from 'src/database/commands/upgrade-version-command/1-16/1-16-make-index-metadata-universal-identifier-and-application-id-not-nullable-migration.command';
import { MakeObjectMetadataUniversalIdentifierAndApplicationIdNotNullableMigrationCommand } from 'src/database/commands/upgrade-version-command/1-16/1-16-make-object-metadata-universal-identifier-and-application-id-not-nullable-migration.command';
-import { IdentifyRemainingEntitiesMetadataCommand } from 'src/database/commands/upgrade-version-command/1-16/1-16-identify-remaining-entities-metadata.command';
import { MakeRemainingEntitiesUniversalIdentifierAndApplicationIdNotNullableMigrationCommand } from 'src/database/commands/upgrade-version-command/1-16/1-16-make-remaining-entities-universal-identifier-and-application-id-not-nullable-migration.command';
import { MakeRoleUniversalIdentifierAndApplicationIdNotNullableMigrationCommand } from 'src/database/commands/upgrade-version-command/1-16/1-16-make-role-universal-identifier-and-application-id-not-nullable-migration.command';
import { MakeViewFieldUniversalIdentifierAndApplicationIdNotNullableMigrationCommand } from 'src/database/commands/upgrade-version-command/1-16/1-16-make-view-field-universal-identifier-and-application-id-not-nullable-migration.command';
@@ -41,6 +42,7 @@ import { ViewEntity } from 'src/engine/metadata-modules/view/entities/view.entit
import { GlobalWorkspaceDataSourceModule } from 'src/engine/twenty-orm/global-workspace-datasource/global-workspace-datasource.module';
import { WorkspaceCacheModule } from 'src/engine/workspace-cache/workspace-cache.module';
import { TwentyStandardApplicationModule } from 'src/engine/workspace-manager/twenty-standard-application/twenty-standard-application.module';
+import { WorkspaceMigrationRunnerModule } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-runner/workspace-migration-runner.module';
import { WorkspaceMigrationModule } from 'src/engine/workspace-manager/workspace-migration/workspace-migration.module';
@Module({
@@ -64,6 +66,7 @@ import { WorkspaceMigrationModule } from 'src/engine/workspace-manager/workspace
GlobalWorkspaceDataSourceModule,
TwentyStandardApplicationModule,
WorkspaceMigrationModule,
+ WorkspaceMigrationRunnerModule,
WorkspaceManyOrAllFlatEntityMapsCacheModule,
],
providers: [
@@ -90,6 +93,7 @@ import { WorkspaceMigrationModule } from 'src/engine/workspace-manager/workspace
MakeIndexMetadataUniversalIdentifierAndApplicationIdNotNullableMigrationCommand,
MakeRemainingEntitiesUniversalIdentifierAndApplicationIdNotNullableMigrationCommand,
IdentifyRemainingEntitiesMetadataCommand,
+ FlushV2CacheAndIncrementMetadataVersionCommand,
],
exports: [
UpdateTaskOnDeleteActionCommand,
@@ -115,6 +119,7 @@ import { WorkspaceMigrationModule } from 'src/engine/workspace-manager/workspace
MakeIndexMetadataUniversalIdentifierAndApplicationIdNotNullableMigrationCommand,
MakeRemainingEntitiesUniversalIdentifierAndApplicationIdNotNullableMigrationCommand,
IdentifyRemainingEntitiesMetadataCommand,
+ FlushV2CacheAndIncrementMetadataVersionCommand,
],
})
export class V1_16_UpgradeVersionCommandModule {}
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/upgrade.command.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/upgrade.command.ts
index 077a1eda28b..bd9a990068a 100644
--- a/packages/twenty-server/src/database/commands/upgrade-version-command/upgrade.command.ts
+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/upgrade.command.ts
@@ -24,6 +24,7 @@ import { FixNanPositionValuesInNotesCommand } from 'src/database/commands/upgrad
import { MigratePageLayoutWidgetConfigurationCommand } from 'src/database/commands/upgrade-version-command/1-15/1-15-migrate-page-layout-widget-configuration.command';
import { BackfillOpportunityOwnerFieldCommand } from 'src/database/commands/upgrade-version-command/1-16/1-16-backfill-opportunity-owner-field.command';
import { BackfillStandardPageLayoutsCommand } from 'src/database/commands/upgrade-version-command/1-16/1-16-backfill-standard-page-layouts.command';
+import { FlushV2CacheAndIncrementMetadataVersionCommand } from 'src/database/commands/upgrade-version-command/1-16/1-16-flush-v2-cache-and-increment-metadata-version.command';
import { IdentifyAgentMetadataCommand } from 'src/database/commands/upgrade-version-command/1-16/1-16-identify-agent-metadata.command';
import { IdentifyFieldMetadataCommand } from 'src/database/commands/upgrade-version-command/1-16/1-16-identify-field-metadata.command';
import { IdentifyIndexMetadataCommand } from 'src/database/commands/upgrade-version-command/1-16/1-16-identify-index-metadata.command';
@@ -108,6 +109,7 @@ export class UpgradeCommand extends UpgradeCommandRunner {
protected readonly makeIndexMetadataUniversalIdentifierAndApplicationIdNotNullableMigrationCommand: MakeIndexMetadataUniversalIdentifierAndApplicationIdNotNullableMigrationCommand,
protected readonly identifyRemainingEntitiesMetadataCommand: IdentifyRemainingEntitiesMetadataCommand,
protected readonly makeRemainingEntitiesUniversalIdentifierAndApplicationIdNotNullableMigrationCommand: MakeRemainingEntitiesUniversalIdentifierAndApplicationIdNotNullableMigrationCommand,
+ protected readonly flushV2CacheAndIncrementMetadataVersionCommand: FlushV2CacheAndIncrementMetadataVersionCommand,
// 1.17 Commands
protected readonly migrateAttachmentToMorphRelationsCommand: MigrateAttachmentToMorphRelationsCommand,
@@ -178,6 +180,7 @@ export class UpgradeCommand extends UpgradeCommandRunner {
this.identifyRemainingEntitiesMetadataCommand,
this
.makeRemainingEntitiesUniversalIdentifierAndApplicationIdNotNullableMigrationCommand,
+ this.flushV2CacheAndIncrementMetadataVersionCommand,
];
const commands_1170: VersionCommands = [
diff --git a/packages/twenty-server/src/engine/metadata-modules/flat-entity/services/workspace-many-or-all-flat-entity-maps-cache.module.ts b/packages/twenty-server/src/engine/metadata-modules/flat-entity/services/workspace-many-or-all-flat-entity-maps-cache.module.ts
index 99882a02b58..be2fbc436c6 100644
--- a/packages/twenty-server/src/engine/metadata-modules/flat-entity/services/workspace-many-or-all-flat-entity-maps-cache.module.ts
+++ b/packages/twenty-server/src/engine/metadata-modules/flat-entity/services/workspace-many-or-all-flat-entity-maps-cache.module.ts
@@ -1,9 +1,6 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
-import { FlatCacheInvalidateCommand } from 'src/engine/core-modules/cache-storage/commands/flat-cache-invalidate.command';
-import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
-import { DataSourceModule } from 'src/engine/metadata-modules/data-source/data-source.module';
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
import { WorkspaceManyOrAllFlatEntityMapsCacheService } from 'src/engine/metadata-modules/flat-entity/services/workspace-many-or-all-flat-entity-maps-cache.service';
import { WorkspaceFlatFieldMetadataMapCacheService } from 'src/engine/metadata-modules/flat-field-metadata/services/workspace-flat-field-metadata-map-cache.service';
@@ -37,9 +34,7 @@ import { WorkspaceCacheModule } from 'src/engine/workspace-cache/workspace-cache
@Module({
imports: [
WorkspaceCacheModule,
- DataSourceModule,
TypeOrmModule.forFeature([
- WorkspaceEntity,
ViewEntity,
ViewFieldEntity,
ViewFilterEntity,
@@ -71,7 +66,6 @@ import { WorkspaceCacheModule } from 'src/engine/workspace-cache/workspace-cache
WorkspaceFlatPageLayoutWidgetMapCacheService,
WorkspaceFlatRowLevelPermissionPredicateMapCacheService,
WorkspaceFlatRowLevelPermissionPredicateGroupMapCacheService,
- FlatCacheInvalidateCommand,
],
exports: [
WorkspaceManyOrAllFlatEntityMapsCacheService,
@@ -88,7 +82,6 @@ import { WorkspaceCacheModule } from 'src/engine/workspace-cache/workspace-cache
WorkspaceFlatPageLayoutWidgetMapCacheService,
WorkspaceFlatRowLevelPermissionPredicateMapCacheService,
WorkspaceFlatRowLevelPermissionPredicateGroupMapCacheService,
- FlatCacheInvalidateCommand,
],
})
export class WorkspaceManyOrAllFlatEntityMapsCacheModule {}
diff --git a/packages/twenty-server/src/engine/core-modules/cache-storage/commands/flat-cache-invalidate.command.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/commands/flat-cache-invalidate.command.ts
similarity index 87%
rename from packages/twenty-server/src/engine/core-modules/cache-storage/commands/flat-cache-invalidate.command.ts
rename to packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/commands/flat-cache-invalidate.command.ts
index 9dd56f81f1e..6f4e5ceb188 100644
--- a/packages/twenty-server/src/engine/core-modules/cache-storage/commands/flat-cache-invalidate.command.ts
+++ b/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/commands/flat-cache-invalidate.command.ts
@@ -14,10 +14,11 @@ import {
import { type RunOnWorkspaceArgs } from 'src/database/commands/command-runners/workspaces-migration.command-runner';
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
import { DataSourceService } from 'src/engine/metadata-modules/data-source/data-source.service';
-import { WorkspaceManyOrAllFlatEntityMapsCacheService } from 'src/engine/metadata-modules/flat-entity/services/workspace-many-or-all-flat-entity-maps-cache.service';
+import { type AllFlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/types/all-flat-entity-maps.type';
import { getMetadataFlatEntityMapsKey } from 'src/engine/metadata-modules/flat-entity/utils/get-metadata-flat-entity-maps-key.util';
import { getMetadataRelatedMetadataNames } from 'src/engine/metadata-modules/flat-entity/utils/get-metadata-related-metadata-names.util';
import { GlobalWorkspaceOrmManager } from 'src/engine/twenty-orm/global-workspace-datasource/global-workspace-orm.manager';
+import { WorkspaceMigrationRunnerService } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-runner/services/workspace-migration-runner.service';
type FlatCacheFlushCommandOptions =
ActiveOrSuspendedWorkspacesMigrationCommandOptions & {
@@ -31,16 +32,14 @@ type FlatCacheFlushCommandOptions =
})
export class FlatCacheInvalidateCommand extends ActiveOrSuspendedWorkspacesMigrationCommandRunner<FlatCacheFlushCommandOptions> {
private metadataNames: string[] = [];
- private flatMapsKeysToFlush: ReturnType<
- typeof getMetadataFlatEntityMapsKey
- >[] = [];
+ private flatMapsKeysToFlush: (keyof AllFlatEntityMaps)[] = [];
constructor(
@InjectRepository(WorkspaceEntity)
protected readonly workspaceRepository: Repository<WorkspaceEntity>,
protected readonly globalWorkspaceOrmManager: GlobalWorkspaceOrmManager,
protected readonly dataSourceService: DataSourceService,
- private readonly flatEntityMapsCacheService: WorkspaceManyOrAllFlatEntityMapsCacheService,
+ private readonly workspaceMigrationRunnerService: WorkspaceMigrationRunnerService,
) {
super(workspaceRepository, globalWorkspaceOrmManager, dataSourceService);
}
@@ -102,12 +101,14 @@ export class FlatCacheInvalidateCommand extends ActiveOrSuspendedWorkspacesMigra
override async runOnWorkspace({
workspaceId,
}: RunOnWorkspaceArgs): Promise<void> {
- await this.flatEntityMapsCacheService.invalidateFlatEntityMaps({
+ await this.workspaceMigrationRunnerService.invalidateCache({
+ allFlatEntityMapsKeys: this.flatMapsKeysToFlush,
workspaceId,
- flatMapsKeys: this.flatMapsKeysToFlush,
});
- this.logger.log(`Successfully flushed cache for workspace: ${workspaceId}`);
+ this.logger.log(
+ `Successfully invalidated cache for workspace: ${workspaceId}`,
+ );
}
private validateAndExpandMetadataNames({
diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/services/workspace-migration-runner.service.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/services/workspace-migration-runner.service.ts
index ffddc8e81a8..6c495565934 100644
--- a/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/services/workspace-migration-runner.service.ts
+++ b/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/services/workspace-migration-runner.service.ts
@@ -14,7 +14,6 @@ import { WorkspaceMetadataVersionService } from 'src/engine/metadata-modules/wor
import { WorkspaceCacheStorageService } from 'src/engine/workspace-cache-storage/workspace-cache-storage.service';
import { WorkspaceCacheService } from 'src/engine/workspace-cache/services/workspace-cache.service';
import { WorkspaceMigration } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-builder/types/workspace-migration';
-import { WorkspaceMigrationAction } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-builder/types/workspace-migration-action-common';
import {
WorkspaceMigrationRunnerException,
WorkspaceMigrationRunnerExceptionCode,
@@ -35,19 +34,18 @@ export class WorkspaceMigrationRunnerService {
) {}
private getLegacyCacheInvalidationPromises({
- workspaceMigration: { actions, workspaceId },
+ allFlatEntityMapsKeys,
+ workspaceId,
}: {
- workspaceMigration: Omit<WorkspaceMigration, 'relatedFlatEntityMapsKeys'>;
+ allFlatEntityMapsKeys: (keyof AllFlatEntityMaps)[];
+ workspaceId: string;
}): Promise<void>[] {
const asyncOperations: Promise<void>[] = [];
- const shouldIncrementMetadataGraphqlSchemaVersion = actions.some(
- (action) => {
- return (
- action.metadataName === 'objectMetadata' ||
- action.metadataName === 'fieldMetadata'
- );
- },
- );
+ const flatMapsKeysSet = new Set(allFlatEntityMapsKeys);
+
+ const shouldIncrementMetadataGraphqlSchemaVersion =
+ flatMapsKeysSet.has('flatObjectMetadataMaps') ||
+ flatMapsKeysSet.has('flatFieldMetadataMaps');
if (shouldIncrementMetadataGraphqlSchemaVersion) {
asyncOperations.push(
@@ -57,16 +55,15 @@ export class WorkspaceMigrationRunnerService {
);
}
- const viewRelatedMetadataNames = [
- 'view',
- 'viewFilter',
- 'viewGroup',
- 'viewField',
- 'viewFilterGroup',
+ const viewRelatedFlatMapsKeys: (keyof AllFlatEntityMaps)[] = [
+ 'flatViewMaps',
+ 'flatViewFilterMaps',
+ 'flatViewGroupMaps',
+ 'flatViewFieldMaps',
+ 'flatViewFilterGroupMaps',
];
- const shouldInvalidFindCoreViewsGraphqlCacheOperation = actions.some(
- (action) => viewRelatedMetadataNames.includes(action.metadataName),
- );
+ const shouldInvalidFindCoreViewsGraphqlCacheOperation =
+ viewRelatedFlatMapsKeys.some((key) => flatMapsKeysSet.has(key));
if (
shouldInvalidFindCoreViewsGraphqlCacheOperation ||
@@ -80,11 +77,9 @@ export class WorkspaceMigrationRunnerService {
);
}
- const shouldInvalidateRoleMapCache = actions.some((action) => {
- return (
- action.metadataName === 'role' || action.metadataName === 'roleTarget'
- );
- });
+ const shouldInvalidateRoleMapCache =
+ flatMapsKeysSet.has('flatRoleMaps') ||
+ flatMapsKeysSet.has('flatRoleTargetMaps');
if (
shouldIncrementMetadataGraphqlSchemaVersion ||
@@ -105,14 +100,12 @@ export class WorkspaceMigrationRunnerService {
return asyncOperations;
}
- private async invalidateCachePostExecution({
+ async invalidateCache({
allFlatEntityMapsKeys,
workspaceId,
- actions,
}: {
allFlatEntityMapsKeys: (keyof AllFlatEntityMaps)[];
workspaceId: string;
- actions: WorkspaceMigrationAction[];
}): Promise<void> {
this.logger.time(
'Runner',
@@ -126,10 +119,8 @@ export class WorkspaceMigrationRunnerService {
const invalidationResults = await Promise.allSettled(
this.getLegacyCacheInvalidationPromises({
- workspaceMigration: {
- actions,
- workspaceId,
- },
+ allFlatEntityMapsKeys,
+ workspaceId,
}),
);
@@ -214,10 +205,9 @@ export class WorkspaceMigrationRunnerService {
this.logger.timeEnd('Runner', 'Transaction execution');
- await this.invalidateCachePostExecution({
+ await this.invalidateCache({
allFlatEntityMapsKeys,
workspaceId,
- actions,
});
this.logger.timeEnd('Runner', 'Total execution');
diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/workspace-migration-runner.module.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/workspace-migration-runner.module.ts
index 608da845d16..0a7eb7d09d5 100644
--- a/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/workspace-migration-runner.module.ts
+++ b/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/workspace-migration-runner.module.ts
@@ -1,14 +1,17 @@
import { Module } from '@nestjs/common';
import { DiscoveryModule } from '@nestjs/core';
+import { TypeOrmModule } from '@nestjs/typeorm';
import { TypeORMModule } from 'src/database/typeorm/typeorm.module';
import { FeatureFlagModule } from 'src/engine/core-modules/feature-flag/feature-flag.module';
+import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
import { DataSourceModule } from 'src/engine/metadata-modules/data-source/data-source.module';
import { WorkspaceManyOrAllFlatEntityMapsCacheModule } from 'src/engine/metadata-modules/flat-entity/services/workspace-many-or-all-flat-entity-maps-cache.module';
import { WorkspaceMetadataVersionModule } from 'src/engine/metadata-modules/workspace-metadata-version/workspace-metadata-version.module';
import { WorkspaceCacheStorageModule } from 'src/engine/workspace-cache-storage/workspace-cache-storage.module';
import { WorkspaceCacheModule } from 'src/engine/workspace-cache/workspace-cache.module';
import { WorkspaceSchemaMigrationRunnerActionHandlersModule } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-runner/action-handlers/workspace-schema-migration-runner-action-handlers.module';
+import { FlatCacheInvalidateCommand } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-runner/commands/flat-cache-invalidate.command';
import { WorkspaceMigrationRunnerActionHandlerRegistryService } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-runner/registry/workspace-migration-runner-action-handler-registry.service';
import { WorkspaceMigrationRunnerService } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-runner/services/workspace-migration-runner.service';
@@ -23,10 +26,12 @@ import { WorkspaceMigrationRunnerService } from 'src/engine/workspace-manager/wo
DiscoveryModule,
WorkspaceCacheStorageModule,
WorkspaceCacheModule,
+ TypeOrmModule.forFeature([WorkspaceEntity]),
],
providers: [
WorkspaceMigrationRunnerService,
WorkspaceMigrationRunnerActionHandlerRegistryService,
+ FlatCacheInvalidateCommand,
],
exports: [WorkspaceMigrationRunnerService],
})