SIGN IN SIGN UP

Remove dead code left behind by the v1 workspace ORM (#24737)

## What

Follow-up to #24718. A dead-code sweep over what the v1 workspace ORM
removal left behind: every file under `twenty-orm/` was checked for
remaining importers (path and symbol level), and the ones whose last
caller was deleted with v1 are removed here.

## Deleted (zero non-test callers, verified by symbol grep)

-
`entity-manager/types/deep-partial-entity-with-nested-relation-fields.type.ts`
- `exceptions/relation.exception.ts`
- `utils/convert-relation-type-to-typeorm-relation-type.util.ts` (fed
the deleted entity-schema factories)
- `utils/apply-table-alias-on-where-condition.ts` + spec
- `utils/get-default-columns-for-index.util.ts` + spec
- `workspace-schema-manager/utils/sanitize-default-value.util.ts` + spec
(column DDL goes through `build-sql-column-definition`, which never used
it)

## Trimmed

- **`repository/permissions.utils.ts`** (663 → 350 lines):
`validateQueryIsPermittedOrThrow` and its `QueryExpressionMap` helpers
were the v1 query-builder permission gate and have no callers left. The
half v2 calls (`validateOperationIsPermittedOrThrow` and the
field-permission validators) is untouched.
- **`ORMWorkspaceContext.entityMetadatas`**: always `[]` since the v1
metadata graph stopped being built, and nothing reads it. Field and
writers removed.
- **`ReflectMetadataTypeMap`**: every `workspace:*` reflect key appears
exactly once in the tree, in the map itself. No decorator writes or
reads them anymore, so the entries are pruned, which also deletes
`interfaces/gate.interface.ts`. The live keys (`config-variables`,
`feature-flag-metadata-args`) stay.

## Deliberately untouched (candidates for later, called out for
visibility)

- **`WorkspaceORMEntityMetadatasCacheService` and the
`ORMEntityMetadatas` cache key**: still invalidated by the committed 2-8
upgrade command and the migration runner, so removing them means
touching committed command logic. Left as is.
- **The v2 query builder's `expressionMap` shim**: looks like a v1
leftover but is live, `joinAttributes` is read by the v2 repository and
the query parsers.
- **Cosmetic moves**: v2-only helpers still living under `twenty-orm/`
(`format-result`, `files-field-sync`, `relation-nested-queries`,
`permissions.utils`, the workspace-schema-manager), the
`GlobalWorkspaceDataSourceModule` name, and the `twenty-orm-v2` suffix
itself. All pure-churn renames better done as a dedicated mechanical PR
if wanted.
- **`object-metadata-repository` +
`WorkspaceDataSourceService.executeRawQuery`**: the pre-v1 legacy
repository layer, down to 2 repositories (Blocklist, TimelineActivity)
but still live in ~10 modules. A migration task, not dead code.

## Verification

- `tsgo --noEmit`: clean
- `oxlint --type-aware` + `oxfmt` on changed files: clean
- All `twenty-orm` + `twenty-orm-v2` unit suites: 42 suites, 405 tests
pass


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/twentyhq/twenty/pull/24737?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
C
Charles Bochet committed
b8125d2bc7fa7bc8074c5abf63c51c4c021b394f
Parent: 97082f0
Committed by GitHub <noreply@github.com> on 8/25/2026, 9:33:06 AM