The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Move the unpin creation commands upgrade command to 2.42 and use the legacy path (#26132)
Paul Rastoinede9bbb3744f
diff --git a/packages/twenty-server/docs/UPGRADE_COMMANDS.md b/packages/twenty-server/docs/UPGRADE_COMMANDS.mdindex 4dee830fbe5..76ce9c8efae 100644--- a/packages/twenty-server/docs/UPGRADE_COMMANDS.md+++ b/packages/twenty-server/docs/UPGRADE_COMMANDS.md@@ -110,15 +110,18 @@ The base class `ActiveOrSuspendedWorkspaceCommandRunner` handles workspace iteraCommands that build a metadata migration go through `WorkspaceMigrationValidateBuildAndRunService`. Two entry points exist:-- `validateBuildAndRunWorkspaceMigration` (default): runs the operation matrix through the metadata side-effect engine (`expandWithSideEffects`) before building. The engine injects and cascades engine-owned companions (system fields and relations, the `searchVector` field and its GIN index, `searchFieldMetadata` rows, unique backing indexes). This is what the live API and application manifests rely on, so new commands should use it.+- `validateBuildAndRunWorkspaceMigration` (default): runs the operation matrix through the metadata side-effect engine (`expandWithSideEffects`) before building. The engine injects and cascades engine-owned companions (system fields and relations, the `searchVector` field and its GIN index, `searchFieldMetadata` rows, unique backing indexes). This is what the live API and application manifests rely on, so commands that create or mutate custom or application-owned metadata should use it.- `validateBuildAndRunLegacyWorkspaceMigration`: skips side-effect expansion and applies the matrix literally, exactly as it was authored.The side-effect engine landed in v2.19. Commands authored before then declared their companions explicitly and were never designed to flow through the engine. Running them through it retroactively changes their behavior: it can hard-fail on reserved-identifier collisions (`RESERVED_SYSTEM_UNIVERSAL_IDENTIFIER`) and silently create rows the command never intended (for example, the deterministic `searchFieldMetadata` rows that the standalone `upgrade:2-16:backfill-search-field-metadata` backfill then re-inserts, hitting `IDX_SEARCH_FIELD_METADATA_OBJECT_FIELD_UNIQUE`).+twenty standard metadata never flows through the engine either: `twenty-standard` declares its companions itself and syncs through the FromTo path. An upgrade command that mutates twenty standard entities (`isSystemBuild: true` with the twenty standard application universal identifier, for example updating a standard `commandMenuItem`) must apply its matrix literally with the legacy method whatever its target version, as `upgrade:2-41:move-message-campaign-commands-to-campaign-flag` and `upgrade:2-42:unpin-creation-commands-on-record-selection` do.+Rule of thumb:+- Operations on **twenty standard** metadata, any version → use the **legacy** method.- Target version **< 2.19** → use the **legacy** method.-- Target version **>= 2.19** → use the default side-effect method.+- Target version **>= 2.19** on custom or application-owned metadata → use the default side-effect method.All pre-2.19 commands follow this rule, including `upgrade:2-10:sync-call-recording-standard-objects`: it builds its create-set from the static twenty-standard definition (which declares all of `callRecording`'s fields, including the `searchVector` system field) and runs it through the legacy path so nothing is injected on top. Its matrix contains no `searchFieldMetadata` operations; the deterministic rows are created later in the same upgrade pipeline by `upgrade:2-16:backfill-search-field-metadata`, which derives them from the standard definition.diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/2-41/2-41-upgrade-version-command.module.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/2-41/2-41-upgrade-version-command.module.tsindex 218ec21c7b5..64546527dd8 100644--- a/packages/twenty-server/src/database/commands/upgrade-version-command/2-41/2-41-upgrade-version-command.module.ts+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/2-41/2-41-upgrade-version-command.module.ts@@ -13,7 +13,6 @@ import { RemoveSeeActiveVersionCommandMenuItemCommand } from 'src/database/commaimport { NormalizeWorkflowRecordCrudRichTextFieldsCommand } from 'src/database/commands/upgrade-version-command/2-41/2-41-workspace-command-1789482628000-normalize-workflow-record-crud-rich-text-fields.command';import { BackfillDeterministicPermissionUniversalIdentifiersCommand } from 'src/database/commands/upgrade-version-command/2-41/2-41-workspace-command-1789553327000-backfill-deterministic-permission-universal-identifiers.command';import { SeedObjectInitialViewCommand } from 'src/database/commands/upgrade-version-command/2-41/2-41-workspace-command-1789565000000-seed-object-initial-view.command';-import { UnpinCreationCommandsOnRecordSelectionCommand } from 'src/database/commands/upgrade-version-command/2-41/2-41-workspace-command-1789565075331-unpin-creation-commands-on-record-selection.command';import { ApplicationModule } from 'src/engine/core-modules/application/application.module';import { WorkflowVersionCoreModule } from 'src/engine/core-modules/workflow/workflow-version-core.module';import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';@@ -47,7 +46,6 @@ import { WorkspaceSchemaMigrationRunnerActionHandlersModule } from 'src/engine/wNormalizeWorkflowRecordCrudRichTextFieldsCommand,BackfillDeterministicPermissionUniversalIdentifiersCommand,SeedObjectInitialViewCommand,- UnpinCreationCommandsOnRecordSelectionCommand,],})export class V2_41_UpgradeVersionCommandModule {}diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/2-42/2-42-upgrade-version-command.module.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/2-42/2-42-upgrade-version-command.module.tsnew file mode 100644index 00000000000..09257f6ad32--- /dev/null+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/2-42/2-42-upgrade-version-command.module.ts@@ -0,0 +1,20 @@+import { Module } from '@nestjs/common';++import { WorkspaceIteratorModule } from 'src/database/commands/command-runners/workspace-iterator.module';+import { UnpinCreationCommandsOnRecordSelectionCommand } from 'src/database/commands/upgrade-version-command/2-42/2-42-workspace-command-1789634112046-unpin-creation-commands-on-record-selection.command';+import { WorkspaceCacheModule } from 'src/engine/workspace-cache/workspace-cache.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';+import { WorkspaceSchemaMigrationRunnerActionHandlersModule } from 'src/engine/workspace-manager/workspace-migration/workspace-migration-runner/action-handlers/workspace-schema-migration-runner-action-handlers.module';++@Module({+ imports: [+ WorkspaceCacheModule,+ WorkspaceIteratorModule,+ WorkspaceMigrationModule,+ WorkspaceMigrationRunnerModule,+ WorkspaceSchemaMigrationRunnerActionHandlersModule,+ ],+ providers: [UnpinCreationCommandsOnRecordSelectionCommand],+})+export class V2_42_UpgradeVersionCommandModule {}diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/2-41/2-41-workspace-command-1789565075331-unpin-creation-commands-on-record-selection.command.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/2-42/2-42-workspace-command-1789634112046-unpin-creation-commands-on-record-selection.command.tssimilarity index 93%rename from packages/twenty-server/src/database/commands/upgrade-version-command/2-41/2-41-workspace-command-1789565075331-unpin-creation-commands-on-record-selection.command.tsrename to packages/twenty-server/src/database/commands/upgrade-version-command/2-42/2-42-workspace-command-1789634112046-unpin-creation-commands-on-record-selection.command.tsindex 0f10234b57d..8a3926da288 100644--- a/packages/twenty-server/src/database/commands/upgrade-version-command/2-41/2-41-workspace-command-1789565075331-unpin-creation-commands-on-record-selection.command.ts+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/2-42/2-42-workspace-command-1789634112046-unpin-creation-commands-on-record-selection.command.ts@@ -4,15 +4,15 @@ import { TWENTY_STANDARD_APPLICATION_UNIVERSAL_IDENTIFIER } from 'twenty-shared/import { ProvisionedWorkspaceCommandRunner } from 'src/database/commands/command-runners/provisioned-workspace.command-runner';import { WorkspaceIteratorService } from 'src/database/commands/command-runners/workspace-iterator.service';import { type RunOnWorkspaceArgs } from 'src/database/commands/command-runners/workspace.command-runner';-import { buildUnpinCreationCommandsOnSelectionUpdates } from 'src/database/commands/upgrade-version-command/2-41/utils/build-unpin-creation-commands-on-selection-updates.util';+import { buildUnpinCreationCommandsOnSelectionUpdates } from 'src/database/commands/upgrade-version-command/2-42/utils/build-unpin-creation-commands-on-selection-updates.util';import { RegisteredWorkspaceCommand } from 'src/engine/core-modules/upgrade/decorators/registered-workspace-command.decorator';import { WorkspaceCacheService } from 'src/engine/workspace-cache/services/workspace-cache.service';import { WorkspaceMigrationBuilderException } from 'src/engine/workspace-manager/workspace-migration/exceptions/workspace-migration-builder-exception';import { WorkspaceMigrationValidateBuildAndRunService } from 'src/engine/workspace-manager/workspace-migration/services/workspace-migration-validate-build-and-run-service';-@RegisteredWorkspaceCommand('2.41.0', 1789565075331)+@RegisteredWorkspaceCommand('2.42.0', 1789634112046)@Command({- name: 'upgrade:2-41:unpin-creation-commands-on-record-selection',+ name: 'upgrade:2-42:unpin-creation-commands-on-record-selection',description:'Stop pinning the record and campaign creation command menu items while records are selected',})@@ -54,7 +54,7 @@ export class UnpinCreationCommandsOnRecordSelectionCommand extends ProvisionedWo}const validateAndBuildResult =- await this.workspaceMigrationValidateBuildAndRunService.validateBuildAndRunWorkspaceMigration(+ await this.workspaceMigrationValidateBuildAndRunService.validateBuildAndRunLegacyWorkspaceMigration({isSystemBuild: true,workspaceId,diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/2-41/utils/__tests__/build-unpin-creation-commands-on-selection-updates.util.spec.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/2-42/utils/__tests__/build-unpin-creation-commands-on-selection-updates.util.spec.tssimilarity index 97%rename from packages/twenty-server/src/database/commands/upgrade-version-command/2-41/utils/__tests__/build-unpin-creation-commands-on-selection-updates.util.spec.tsrename to packages/twenty-server/src/database/commands/upgrade-version-command/2-42/utils/__tests__/build-unpin-creation-commands-on-selection-updates.util.spec.tsindex b658dbccadf..288799557fb 100644--- a/packages/twenty-server/src/database/commands/upgrade-version-command/2-41/utils/__tests__/build-unpin-creation-commands-on-selection-updates.util.spec.ts+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/2-42/utils/__tests__/build-unpin-creation-commands-on-selection-updates.util.spec.ts@@ -1,4 +1,4 @@-import { buildUnpinCreationCommandsOnSelectionUpdates } from 'src/database/commands/upgrade-version-command/2-41/utils/build-unpin-creation-commands-on-selection-updates.util';+import { buildUnpinCreationCommandsOnSelectionUpdates } from 'src/database/commands/upgrade-version-command/2-42/utils/build-unpin-creation-commands-on-selection-updates.util';import { type FlatCommandMenuItem } from 'src/engine/metadata-modules/flat-command-menu-item/types/flat-command-menu-item.type';import { STANDARD_COMMAND_MENU_ITEMS } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-command-menu-item.constant';diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/2-41/utils/build-unpin-creation-commands-on-selection-updates.util.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/2-42/utils/build-unpin-creation-commands-on-selection-updates.util.tssimilarity index 100%rename from packages/twenty-server/src/database/commands/upgrade-version-command/2-41/utils/build-unpin-creation-commands-on-selection-updates.util.tsrename to packages/twenty-server/src/database/commands/upgrade-version-command/2-42/utils/build-unpin-creation-commands-on-selection-updates.util.tsdiff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/workspace-command-provider.module.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/workspace-command-provider.module.tsindex abb468d7147..b2dc3999742 100644--- a/packages/twenty-server/src/database/commands/upgrade-version-command/workspace-command-provider.module.ts+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/workspace-command-provider.module.ts@@ -34,6 +34,7 @@ import { V2_38_UpgradeVersionCommandModule } from 'src/database/commands/upgradeimport { V2_39_UpgradeVersionCommandModule } from 'src/database/commands/upgrade-version-command/2-39/2-39-upgrade-version-command.module';import { V2_40_UpgradeVersionCommandModule } from 'src/database/commands/upgrade-version-command/2-40/2-40-upgrade-version-command.module';import { V2_41_UpgradeVersionCommandModule } from 'src/database/commands/upgrade-version-command/2-41/2-41-upgrade-version-command.module';+import { V2_42_UpgradeVersionCommandModule } from 'src/database/commands/upgrade-version-command/2-42/2-42-upgrade-version-command.module';import { V2_4_UpgradeVersionCommandModule } from 'src/database/commands/upgrade-version-command/2-4/2-4-upgrade-version-command.module';import { V2_5_UpgradeVersionCommandModule } from 'src/database/commands/upgrade-version-command/2-5/2-5-upgrade-version-command.module';import { V2_7_UpgradeVersionCommandModule } from 'src/database/commands/upgrade-version-command/2-7/2-7-upgrade-version-command.module';@@ -81,6 +82,7 @@ import { V2_9_UpgradeVersionCommandModule } from 'src/database/commands/upgrade-V2_39_UpgradeVersionCommandModule,V2_40_UpgradeVersionCommandModule,V2_41_UpgradeVersionCommandModule,+ V2_42_UpgradeVersionCommandModule,],})export class WorkspaceCommandProviderModule {}