The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
release 1.10 flush cache command (#15610)
Guillime64603e61a8c
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.tsnew file mode 100644index 00000000000..0404defa105--- /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<WorkspaceEntity>,+ protected readonly twentyORMGlobalManager: TwentyORMGlobalManager,+ protected readonly workspaceCacheStorageService: WorkspaceCacheStorageService,+ ) {+ super(workspaceRepository, twentyORMGlobalManager);+ }++ override async runOnWorkspace({+ workspaceId,+ }: RunOnWorkspaceArgs): Promise<void> {+ 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.tsindex 9766d554cb0..a19929c53dc 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-metadatimport { 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-scDataSourceEntity,]),WorkspaceSchemaManagerModule,+ WorkspaceCacheStorageModule,ObjectMetadataModule,],providers: [@@ -42,6 +45,7 @@ import { WorkspaceSchemaManagerModule } from 'src/engine/twenty-orm/workspace-scMakeSureDashboardNamingAvailableCommand,SeedDashboardViewCommand,CreateViewKanbanFieldMetadataIdForeignKeyMigrationCommand,+ FlushCacheCommand,],exports: [MigrateAttachmentAuthorToCreatedByCommand,@@ -53,6 +57,7 @@ import { WorkspaceSchemaManagerModule } from 'src/engine/twenty-orm/workspace-scMakeSureDashboardNamingAvailableCommand,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.tsindex 42eb0684f4a..84f09df4d83 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,],};