Skip to content

chore: remove completed migration feature flags and upgrade commands <= 1.18#19074

Merged
charlesBochet merged 1 commit intomainfrom
chore/remove-migration-feature-flags-and-old-upgrade-commands
Mar 29, 2026
Merged

chore: remove completed migration feature flags and upgrade commands <= 1.18#19074
charlesBochet merged 1 commit intomainfrom
chore/remove-migration-feature-flags-and-old-upgrade-commands

Conversation

@charlesBochet
Copy link
Copy Markdown
Member

@charlesBochet charlesBochet commented Mar 28, 2026

Summary

  • Remove 3 completed migration feature flags: IS_ATTACHMENT_MIGRATED, IS_NOTE_TARGET_MIGRATED, IS_TASK_TARGET_MIGRATED — these were already enabled by default for all new workspaces via DEFAULT_FEATURE_FLAGS
  • Delete all upgrade command directories for versions <= 1.18 (1-16/, 1-17/, 1-18/) along with their module registrations, removing ~6,600 lines of dead migration code
  • Simplify frontend utility functions (getActivityTargetObjectFieldIdName, getActivityTargetsFilter, getActivityTargetFieldNameForObject, generateActivityTargetMorphFieldKeys, findActivitiesOperationSignatureFactory) by removing the isMorphRelation parameter and always using the morph relation path
  • Remove feature flag checks from 7 frontend hooks/components that were gating attachment and activity target behavior behind the removed flags
  • Simplify buildDefaultRelationFlatFieldMetadatasForCustomObject server util to always treat attachment, noteTarget, and taskTarget as morph relations without checking feature flags

Copilot AI review requested due to automatic review settings March 28, 2026 22:23
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 47 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/twenty-server/src/engine/constants/upgrade-command-supported-versions.constant.ts">

<violation number="1" location="packages/twenty-server/src/engine/constants/upgrade-command-supported-versions.constant.ts:1">
P1: Removing `1.18.0` breaks the `1.19.x` upgrade path because `getPreviousVersion()` can no longer resolve a source version for the registered `1.19.0` commands.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes now-obsolete migration feature flags and deprecates upgrade command support for versions ≤ 1.18, while simplifying activity/attachment targeting logic to always use the morph-relation path across server and frontend.

Changes:

  • Removed completed migration feature flags (IS_ATTACHMENT_MIGRATED, IS_NOTE_TARGET_MIGRATED, IS_TASK_TARGET_MIGRATED) and their default/seeded behavior.
  • Dropped upgrade-command implementations and module registrations for versions 1.16, 1.17, and 1.18, and narrowed supported upgrade versions to 1.19 and 1.20.
  • Simplified frontend activity targeting utilities/hooks/components by removing the isMorphRelation branching and always using morph field naming.

Reviewed changes

Copilot reviewed 47 out of 47 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/twenty-shared/src/types/FeatureFlagKey.ts Removes completed migration feature flag keys from the shared enum.
packages/twenty-server/src/engine/workspace-manager/workspace-migration/constant/default-feature-flags.ts Clears default feature flags list (now empty) after flag removal.
packages/twenty-server/src/engine/workspace-manager/dev-seeder/core/utils/seed-feature-flags.util.ts Stops seeding removed migration flags.
packages/twenty-server/src/engine/twenty-orm/entity-manager/workspace-entity-manager.spec.ts Updates expected feature flag maps in tests after flag removal.
packages/twenty-server/src/engine/metadata-modules/object-metadata/utils/build-default-relation-flat-field-metadatas-for-custom-object.util.ts Always treats attachment/noteTarget/taskTarget as morph relations (no feature-flag gating).
packages/twenty-server/src/engine/metadata-modules/object-metadata/object-metadata.service.ts Removes passing existingFeatureFlagsMap into object creation flow.
packages/twenty-server/src/engine/metadata-modules/flat-object-metadata/utils/from-create-object-input-to-flat-object-metadata-and-flat-field-metadatas-to-create.util.ts Removes existingFeatureFlagsMap from args and downstream call.
packages/twenty-server/src/engine/constants/upgrade-command-supported-versions.constant.ts Restricts supported upgrade command versions to 1.19 and 1.20 only.
packages/twenty-server/src/database/commands/upgrade-version-command/upgrade.command.ts Removes <=1.18 command wiring and version-to-commands mappings.
packages/twenty-server/src/database/commands/upgrade-version-command/upgrade-version-command.module.ts Removes 1.17/1.18 module imports/registration.
packages/twenty-server/src/database/commands/upgrade-version-command/1-18/1-18-upgrade-version-command.module.ts Deleted deprecated 1.18 upgrade module.
packages/twenty-server/src/database/commands/upgrade-version-command/1-18/1-18-migrate-workspace-pictures.command.ts Deleted deprecated 1.18 command implementation.
packages/twenty-server/src/database/commands/upgrade-version-command/1-18/1-18-migrate-workflow-send-email-attachments.command.ts Deleted deprecated 1.18 command implementation.
packages/twenty-server/src/database/commands/upgrade-version-command/1-18/1-18-migrate-person-avatar-files.command.ts Deleted deprecated 1.18 command implementation.
packages/twenty-server/src/database/commands/upgrade-version-command/1-18/1-18-migrate-favorites-to-navigation-menu-items.command.ts Deleted deprecated 1.18 command implementation.
packages/twenty-server/src/database/commands/upgrade-version-command/1-18/1-18-migrate-attachment-files.command.ts Deleted deprecated 1.18 command implementation.
packages/twenty-server/src/database/commands/upgrade-version-command/1-18/1-18-migrate-activity-rich-text-attachment-file-ids.command.ts Deleted deprecated 1.18 command implementation.
packages/twenty-server/src/database/commands/upgrade-version-command/1-18/1-18-delete-orphan-favorites.command.ts Deleted deprecated 1.18 command implementation.
packages/twenty-server/src/database/commands/upgrade-version-command/1-18/1-18-backfill-standard-views-and-field-metadata.command.ts Deleted deprecated 1.18 command implementation.
packages/twenty-server/src/database/commands/upgrade-version-command/1-18/1-18-backfill-message-channel-throttle-retry-after.command.ts Deleted deprecated 1.18 command implementation.
packages/twenty-server/src/database/commands/upgrade-version-command/1-18/1-18-backfill-file-size-and-mime-type.command.ts Deleted deprecated 1.18 command implementation.
packages/twenty-server/src/database/commands/upgrade-version-command/1-17/utils/migrate-send-email-step.util.ts Deleted deprecated 1.17 utility.
packages/twenty-server/src/database/commands/upgrade-version-command/1-17/utils/tests/migrate-send-email-step.util.spec.ts Deleted deprecated 1.17 tests.
packages/twenty-server/src/database/commands/upgrade-version-command/1-17/1-17-upgrade-version-command.module.ts Deleted deprecated 1.17 module.
packages/twenty-server/src/database/commands/upgrade-version-command/1-17/1-17-migrate-task-target-to-morph-relations.command.ts Deleted deprecated 1.17 command implementation.
packages/twenty-server/src/database/commands/upgrade-version-command/1-17/1-17-migrate-send-email-recipients.command.ts Deleted deprecated 1.17 command implementation.
packages/twenty-server/src/database/commands/upgrade-version-command/1-17/1-17-migrate-note-target-to-morph-relations.command.ts Deleted deprecated 1.17 command implementation.
packages/twenty-server/src/database/commands/upgrade-version-command/1-17/1-17-migrate-date-time-is-filter-values.command.ts Deleted deprecated 1.17 command implementation.
packages/twenty-server/src/database/commands/upgrade-version-command/1-17/1-17-migrate-attachment-to-morph-relations.command.ts Deleted deprecated 1.17 command implementation.
packages/twenty-server/src/database/commands/upgrade-version-command/1-17/1-17-make-webhook-universal-identifier-and-application-id-not-nullable-migration.command.ts Deleted deprecated 1.17 command implementation.
packages/twenty-server/src/database/commands/upgrade-version-command/1-17/1-17-identify-webhook-metadata.command.ts Deleted deprecated 1.17 command implementation.
packages/twenty-server/src/database/commands/upgrade-version-command/1-17/1-17-fix-morph-relation-field-names.command.ts Deleted deprecated 1.17 command implementation.
packages/twenty-server/src/database/commands/upgrade-version-command/1-17/1-17-delete-all-files-and-update-table.command.ts Deleted deprecated 1.17 command implementation.
packages/twenty-server/src/database/commands/upgrade-version-command/1-17/1-17-backfill-application-package-files.command.ts Deleted deprecated 1.17 command implementation.
packages/twenty-server/src/database/commands/upgrade-version-command/1-16/constants/standard-index-field-names.constant.ts Deleted deprecated 1.16 constant data.
packages/twenty-front/src/modules/page-layout/widgets/standalone-rich-text/components/StandaloneRichTextWidget.tsx Removes feature-flag gating; always uses morph field naming for attachment targeting.
packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/components/RichTextFieldEditor.tsx Removes feature-flag gating; always uses morph field naming for attachment targeting.
packages/twenty-front/src/modules/activities/utils/getActivityTargetsFilter.ts Simplifies filter building to always use morph join column naming.
packages/twenty-front/src/modules/activities/utils/getActivityTargetObjectFieldIdName.ts Removes isMorphRelation branching; always returns morph-style field id name.
packages/twenty-front/src/modules/activities/utils/getActivityTargetFieldNameForObject.ts Removes non-morph path; derives target field name from morph-style id name.
packages/twenty-front/src/modules/activities/utils/generateActivityTargetMorphFieldKeys.ts Removes isMorphRelation parameter; always generates morph-style keys.
packages/twenty-front/src/modules/activities/inline-cell/hooks/useUpdateActivityTargetFromCell.ts Removes feature-flag checks and always uses morph naming path.
packages/twenty-front/src/modules/activities/hooks/usePrepareFindManyActivitiesQuery.ts Removes feature-flag checks and always generates morph field signatures.
packages/twenty-front/src/modules/activities/hooks/useActivityTargetsForTargetableObjects.ts Removes feature-flag checks; builds activity target filter via morph path.
packages/twenty-front/src/modules/activities/graphql/operation-signatures/factories/findActivitiesOperationSignatureFactory.ts Removes isMorphRelation branching; always includes morph field keys.
packages/twenty-front/src/modules/activities/files/hooks/useUploadAttachmentFile.tsx Removes feature-flag gating; always sets attachment target via morph join field.
packages/twenty-front/src/modules/activities/files/hooks/useAttachments.tsx Removes feature-flag gating; always filters attachments via morph join field.
Comments suppressed due to low confidence (1)

packages/twenty-front/src/modules/activities/utils/getActivityTargetsFilter.ts:28

  • targetableObjects.map(...) always returns a tuple, so .filter(isDefined) is redundant here. Removing it will simplify the code and avoid implying that undefined entries are expected.
  const findManyActivityTargetsQueryFilter = Object.fromEntries(
    targetableObjects
      .map((targetableObject) => {
        const joinColumnName = getActivityTargetObjectFieldIdName({
          nameSingular: targetableObject.targetObjectNameSingular,
        });

        return [
          joinColumnName,
          {
            eq: targetableObject.id,
          },
        ];
      })
      .filter(isDefined),
  );

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 73 to +77
const isObjectMigratedToMorphRelations =
isObjectMigratedFromOlderReleases || isFeatureFlagEnabled;
objectMetadataNameSingular === 'timelineActivity' ||
objectMetadataNameSingular === 'attachment' ||
objectMetadataNameSingular === 'noteTarget' ||
objectMetadataNameSingular === 'taskTarget';
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isObjectMigratedToMorphRelations is currently hard-coded for a subset of DEFAULT_RELATIONS_OBJECTS_STANDARD_IDS, duplicating knowledge already present in morphIdByRelationObjectNameSingular. This risks the two getting out of sync if objects are added/removed; consider deriving the boolean from the morphId map (e.g., morphIdByRelationObjectNameSingular[name] != null) or using a single source of truth.

Copilot uses AI. Check for mistakes.
…<= 1.18

Remove IS_ATTACHMENT_MIGRATED, IS_NOTE_TARGET_MIGRATED, and
IS_TASK_TARGET_MIGRATED feature flags since these migrations are complete
and the flags were already enabled by default for all new workspaces.

Also delete all upgrade commands for versions <= 1.18 (1-16, 1-17, 1-18
directories) as they are no longer needed.

Frontend utility functions (getActivityTargetObjectFieldIdName,
getActivityTargetsFilter, getActivityTargetFieldNameForObject, etc.)
are simplified to always use the morph relation path, removing the
legacy code branches.

Made-with: Cursor
@charlesBochet charlesBochet force-pushed the chore/remove-migration-feature-flags-and-old-upgrade-commands branch from 00b7679 to a70250b Compare March 28, 2026 22:33
@FelixMalfait
Copy link
Copy Markdown
Member

FelixMalfait commented Mar 28, 2026

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:9588

This environment will automatically shut down after 5 hours.

@FelixMalfait
Copy link
Copy Markdown
Member

📊 API Changes Report

GraphQL Schema Changes

GraphQL Schema Changes

[error] Error: Unable to read JSON file: /home/runner/work/twenty/twenty/main-schema-introspection.json: Not valid JSON content
at JsonFileLoader.handleFileContent (/opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:147:19)
at /opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:95:43
at async Promise.all (index 0)
at async JsonFileLoader.load (/opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:88:9)
at async /opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:15:39
at async Promise.all (index 4)
at async loadFile (/opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:13:9)
at async /opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/collect-sources.js:200:25
Error: Unable to read JSON file: /home/runner/work/twenty/twenty/main-schema-introspection.json: Not valid JSON content
at JsonFileLoader.handleFileContent (/opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:147:19)
at /opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:95:43
at async Promise.all (index 0)
at async JsonFileLoader.load (/opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:88:9)
at async /opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:15:39
at async Promise.all (index 4)
at async loadFile (/opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:13:9)
at async /opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/collect-sources.js:200:25
⚠️ Breaking changes or errors detected in GraphQL schema

[error] Error: Unable to read JSON file: /home/runner/work/twenty/twenty/main-schema-introspection.json: Not valid JSON content
    at JsonFileLoader.handleFileContent (/opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:147:19)
    at /opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:95:43
    at async Promise.all (index 0)
    at async JsonFileLoader.load (/opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:88:9)
    at async /opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:15:39
    at async Promise.all (index 4)
    at async loadFile (/opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:13:9)
    at async /opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/collect-sources.js:200:25
Error generating diff

GraphQL Metadata Schema Changes

GraphQL Metadata Schema Changes

[error] Error: Unable to read JSON file: /home/runner/work/twenty/twenty/main-metadata-schema-introspection.json: Not valid JSON content
at JsonFileLoader.handleFileContent (/opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:147:19)
at /opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:95:43
at async Promise.all (index 0)
at async JsonFileLoader.load (/opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:88:9)
at async /opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:15:39
at async Promise.all (index 4)
at async loadFile (/opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:13:9)
at async /opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/collect-sources.js:200:25
Error: Unable to read JSON file: /home/runner/work/twenty/twenty/main-metadata-schema-introspection.json: Not valid JSON content
at JsonFileLoader.handleFileContent (/opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:147:19)
at /opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:95:43
at async Promise.all (index 0)
at async JsonFileLoader.load (/opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:88:9)
at async /opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:15:39
at async Promise.all (index 4)
at async loadFile (/opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:13:9)
at async /opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/collect-sources.js:200:25
⚠️ Breaking changes or errors detected in GraphQL metadata schema

[error] Error: Unable to read JSON file: /home/runner/work/twenty/twenty/main-metadata-schema-introspection.json: Not valid JSON content
    at JsonFileLoader.handleFileContent (/opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:147:19)
    at /opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:95:43
    at async Promise.all (index 0)
    at async JsonFileLoader.load (/opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/json-file-loader/cjs/index.js:88:9)
    at async /opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:15:39
    at async Promise.all (index 4)
    at async loadFile (/opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:13:9)
    at async /opt/hostedtoolcache/node/24.14.0/x64/lib/node_modules/@graphql-inspector/cli/node_modules/@graphql-tools/load/cjs/load-typedefs/collect-sources.js:200:25
Error generating diff

REST API Analysis Error

⚠️ Error occurred while analyzing REST API changes

Error Output

REST Metadata API Analysis Error

⚠️ Error occurred while analyzing REST Metadata API changes

Error Output

⚠️ Please review these API changes carefully before merging.

@charlesBochet charlesBochet merged commit e8cb086 into main Mar 29, 2026
99 checks passed
@charlesBochet charlesBochet deleted the chore/remove-migration-feature-flags-and-old-upgrade-commands branch March 29, 2026 07:15
@twenty-eng-sync
Copy link
Copy Markdown

Hey @charlesBochet! After you've done the QA of your Pull Request, you can mark it as done here. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants