From e64603e61a8cde65da253764385b4078f3bb2d59 Mon Sep 17 00:00:00 2001 From: Guillim Date: Tue, 4 Nov 2025 17:29:06 +0100 Subject: [PATCH] release 1.10 flush cache command (#15610) --- .../1-10/1-10-flush-cache.command.ts | 34 +++++++++++++++++++ .../1-10-upgrade-version-command.module.ts | 5 +++ .../upgrade.command.ts | 3 ++ 3 files changed, 42 insertions(+) create mode 100644 packages/twenty-server/src/database/commands/upgrade-version-command/1-10/1-10-flush-cache.command.ts diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/1-10/1-10-flush-cache.command.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/1-10/1-10-flush-cache.command.ts new file mode 100644 index 0000000000..0404defa10 --- /dev/null +++ b/packages/twenty-server/src/database/commands/upgrade-version-command/1-10/1-10-flush-cache.command.ts @@ -0,0 +1,34 @@ +import { InjectRepository } from '@nestjs/typeorm'; + +import { Command } from 'nest-commander'; +import { Repository } from 'typeorm'; + +import { + ActiveOrSuspendedWorkspacesMigrationCommandRunner, + type RunOnWorkspaceArgs, +} from 'src/database/commands/command-runners/active-or-suspended-workspaces-migration.command-runner'; +import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity'; +import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager'; +import { WorkspaceCacheStorageService } from 'src/engine/workspace-cache-storage/workspace-cache-storage.service'; + +@Command({ + name: 'upgrade:1-10:flush-cache', + description: 'Flush cache for workspace', +}) +export class FlushCacheCommand extends ActiveOrSuspendedWorkspacesMigrationCommandRunner { + constructor( + @InjectRepository(WorkspaceEntity) + protected readonly workspaceRepository: Repository, + protected readonly twentyORMGlobalManager: TwentyORMGlobalManager, + protected readonly workspaceCacheStorageService: WorkspaceCacheStorageService, + ) { + super(workspaceRepository, twentyORMGlobalManager); + } + + override async runOnWorkspace({ + workspaceId, + }: RunOnWorkspaceArgs): Promise { + this.logger.log(`Flush cache for workspace ${workspaceId}`); + await this.workspaceCacheStorageService.flush(workspaceId); + } +} diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/1-10/1-10-upgrade-version-command.module.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/1-10/1-10-upgrade-version-command.module.ts index 9766d554cb..a19929c53d 100644 --- a/packages/twenty-server/src/database/commands/upgrade-version-command/1-10/1-10-upgrade-version-command.module.ts +++ b/packages/twenty-server/src/database/commands/upgrade-version-command/1-10/1-10-upgrade-version-command.module.ts @@ -4,6 +4,7 @@ import { TypeOrmModule } from '@nestjs/typeorm'; import { AddWorkflowRunStopStatusesCommand } from 'src/database/commands/upgrade-version-command/1-10/1-10-add-workflow-run-stop-statuses.command'; import { CleanOrphanedKanbanAggregateOperationFieldMetadataIdCommand } from 'src/database/commands/upgrade-version-command/1-10/1-10-clean-orphaned-kanban-aggregate-operation-field-metadata-id.command'; import { CreateViewKanbanFieldMetadataIdForeignKeyMigrationCommand } from 'src/database/commands/upgrade-version-command/1-10/1-10-create-view-kanban-field-metadata-id-foreign-key-migration.command'; +import { FlushCacheCommand } from 'src/database/commands/upgrade-version-command/1-10/1-10-flush-cache.command'; import { MakeSureDashboardNamingAvailableCommand } from 'src/database/commands/upgrade-version-command/1-10/1-10-make-sure-dashboard-naming-available.command'; import { MigrateAttachmentAuthorToCreatedByCommand } from 'src/database/commands/upgrade-version-command/1-10/1-10-migrate-attachment-author-to-created-by.command'; import { MigrateAttachmentTypeToFileCategoryCommand } from 'src/database/commands/upgrade-version-command/1-10/1-10-migrate-attachment-type-to-file-category.command'; @@ -18,6 +19,7 @@ import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadat import { ObjectMetadataModule } from 'src/engine/metadata-modules/object-metadata/object-metadata.module'; import { ViewEntity } from 'src/engine/metadata-modules/view/entities/view.entity'; import { WorkspaceSchemaManagerModule } from 'src/engine/twenty-orm/workspace-schema-manager/workspace-schema-manager.module'; +import { WorkspaceCacheStorageModule } from 'src/engine/workspace-cache-storage/workspace-cache-storage.module'; @Module({ imports: [ @@ -30,6 +32,7 @@ import { WorkspaceSchemaManagerModule } from 'src/engine/twenty-orm/workspace-sc DataSourceEntity, ]), WorkspaceSchemaManagerModule, + WorkspaceCacheStorageModule, ObjectMetadataModule, ], providers: [ @@ -42,6 +45,7 @@ import { WorkspaceSchemaManagerModule } from 'src/engine/twenty-orm/workspace-sc MakeSureDashboardNamingAvailableCommand, SeedDashboardViewCommand, CreateViewKanbanFieldMetadataIdForeignKeyMigrationCommand, + FlushCacheCommand, ], exports: [ MigrateAttachmentAuthorToCreatedByCommand, @@ -53,6 +57,7 @@ import { WorkspaceSchemaManagerModule } from 'src/engine/twenty-orm/workspace-sc MakeSureDashboardNamingAvailableCommand, SeedDashboardViewCommand, CreateViewKanbanFieldMetadataIdForeignKeyMigrationCommand, + FlushCacheCommand, ], }) export class V1_10_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 42eb0684f4..84f09df4d8 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 @@ -12,6 +12,7 @@ import { import { AddWorkflowRunStopStatusesCommand } from 'src/database/commands/upgrade-version-command/1-10/1-10-add-workflow-run-stop-statuses.command'; import { CleanOrphanedKanbanAggregateOperationFieldMetadataIdCommand } from 'src/database/commands/upgrade-version-command/1-10/1-10-clean-orphaned-kanban-aggregate-operation-field-metadata-id.command'; import { CreateViewKanbanFieldMetadataIdForeignKeyMigrationCommand } from 'src/database/commands/upgrade-version-command/1-10/1-10-create-view-kanban-field-metadata-id-foreign-key-migration.command'; +import { FlushCacheCommand } from 'src/database/commands/upgrade-version-command/1-10/1-10-flush-cache.command'; import { MakeSureDashboardNamingAvailableCommand } from 'src/database/commands/upgrade-version-command/1-10/1-10-make-sure-dashboard-naming-available.command'; import { MigrateAttachmentAuthorToCreatedByCommand } from 'src/database/commands/upgrade-version-command/1-10/1-10-migrate-attachment-author-to-created-by.command'; import { MigrateAttachmentTypeToFileCategoryCommand } from 'src/database/commands/upgrade-version-command/1-10/1-10-migrate-attachment-type-to-file-category.command'; @@ -67,6 +68,7 @@ export class UpgradeCommand extends UpgradeCommandRunner { protected readonly makeSureDashboardNamingAvailableCommand: MakeSureDashboardNamingAvailableCommand, protected readonly seedDashboardViewCommand: SeedDashboardViewCommand, protected readonly createViewKanbanFieldMetadataIdForeignKeyMigrationCommand: CreateViewKanbanFieldMetadataIdForeignKeyMigrationCommand, + protected readonly flushWorkspaceCacheCommand: FlushCacheCommand, ) { super( workspaceRepository, @@ -111,6 +113,7 @@ export class UpgradeCommand extends UpgradeCommandRunner { this.migrateAttachmentAuthorToCreatedByCommand, this.migrateAttachmentTypeToFileCategoryCommand, this.seedDashboardViewCommand, + this.flushWorkspaceCacheCommand, ], };