The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
fix(upgrade): pin 2.20 messageList view command to its original columns (#26006)
Paul Rastoin3c3615daae51
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/2-20/2-20-workspace-command-1783525261001-create-message-list-view.command.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/2-20/2-20-workspace-command-1783525261001-create-message-list-view.command.tsindex 1ec437b5cba..e063cf65220 100644--- a/packages/twenty-server/src/database/commands/upgrade-version-command/2-20/2-20-workspace-command-1783525261001-create-message-list-view.command.ts+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/2-20/2-20-workspace-command-1783525261001-create-message-list-view.command.ts@@ -22,9 +22,15 @@ const LIST = STANDARD_OBJECTS.messageList;const LIST_VIEW_UNIVERSAL_IDENTIFIER =LIST.views.allMessageLists.universalIdentifier;-const LIST_VIEW_FIELD_UNIVERSAL_IDENTIFIERS = Object.values(- LIST.views.allMessageLists.viewFields,-).map((viewField) => viewField.universalIdentifier);+// Pinned to the columns the view had in 2.20: the description column and its+// field only exist from 2.39, so reading the current standard definition here+// would reference field metadata that later commands have not created yet.+const LIST_VIEW_FIELD_UNIVERSAL_IDENTIFIERS = [+ LIST.views.allMessageLists.viewFields.name.universalIdentifier,+ LIST.views.allMessageLists.viewFields.members.universalIdentifier,+ LIST.views.allMessageLists.viewFields.campaigns.universalIdentifier,+ LIST.views.allMessageLists.viewFields.createdAt.universalIdentifier,+];@RegisteredWorkspaceCommand('2.20.0', 1783525261001)@Command({diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/2-20/__tests__/2-20-workspace-command-1783525261001-create-message-list-view.command.spec.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/2-20/__tests__/2-20-workspace-command-1783525261001-create-message-list-view.command.spec.tsindex 4f546b12db5..d9b09aa4573 100644--- a/packages/twenty-server/src/database/commands/upgrade-version-command/2-20/__tests__/2-20-workspace-command-1783525261001-create-message-list-view.command.spec.ts+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/2-20/__tests__/2-20-workspace-command-1783525261001-create-message-list-view.command.spec.ts@@ -23,9 +23,14 @@ const STANDARD_APPLICATION = {const LIST = STANDARD_OBJECTS.messageList;const LIST_VIEW_UNIVERSAL_IDENTIFIER =LIST.views.allMessageLists.universalIdentifier;-const LIST_VIEW_FIELD_UNIVERSAL_IDENTIFIERS = Object.values(- LIST.views.allMessageLists.viewFields,-).map((viewField) => viewField.universalIdentifier);+const LIST_VIEW_FIELD_UNIVERSAL_IDENTIFIERS = [+ LIST.views.allMessageLists.viewFields.name.universalIdentifier,+ LIST.views.allMessageLists.viewFields.members.universalIdentifier,+ LIST.views.allMessageLists.viewFields.campaigns.universalIdentifier,+ LIST.views.allMessageLists.viewFields.createdAt.universalIdentifier,+];+const DESCRIPTION_VIEW_FIELD_UNIVERSAL_IDENTIFIER =+ LIST.views.allMessageLists.viewFields.description.universalIdentifier;const buildByUniversalIdentifierMap = (universalIdentifiers: string[]) => ({byUniversalIdentifier: Object.fromEntries(@@ -58,9 +63,10 @@ describe('CreateMessageListViewCommand', () => {flatViewMaps: buildByUniversalIdentifierMap([LIST_VIEW_UNIVERSAL_IDENTIFIER,]),- flatViewFieldMaps: buildByUniversalIdentifierMap(- LIST_VIEW_FIELD_UNIVERSAL_IDENTIFIERS,- ),+ flatViewFieldMaps: buildByUniversalIdentifierMap([+ ...LIST_VIEW_FIELD_UNIVERSAL_IDENTIFIERS,+ DESCRIPTION_VIEW_FIELD_UNIVERSAL_IDENTIFIER,+ ]),},});@@ -140,6 +146,22 @@ describe('CreateMessageListViewCommand', () => {).toHaveLength(LIST_VIEW_FIELD_UNIVERSAL_IDENTIFIERS.length);});+ it('leaves the description column to the 2.39 command', async () => {+ mockWorkspaceCache({});++ await runOnWorkspace();++ const createdViewFieldUniversalIdentifiers =+ validateBuildAndRunWorkspaceMigrationMock.mock.calls[0][0].allFlatEntityOperationByMetadataName.viewField.flatEntityToCreate.map(+ ({ universalIdentifier }: { universalIdentifier: string }) =>+ universalIdentifier,+ );++ expect(createdViewFieldUniversalIdentifiers).not.toContain(+ DESCRIPTION_VIEW_FIELD_UNIVERSAL_IDENTIFIER,+ );+ });+it('creates missing view fields when the view already exists', async () => {mockWorkspaceCache({existingViews: [LIST_VIEW_UNIVERSAL_IDENTIFIER],