https://sonarly.com/issue/16678?type=bug The `timelineActivity` table lacks database indexes on foreign key columns created for custom object morph relations, causing a 3,491ms sequential scan when loading a single custom object record's timeline activities. Fix: **What changed:** When creating a custom object, Twenty automatically creates default relations to standard objects like `timelineActivity`, `noteTarget`, `taskTarget`, `attachment`, and `favorite`. The function `generateMorphOrRelationFlatFieldMetadataPair` already generates both the relation field metadata AND a BTREE index on the FK join column for the MANY_TO_ONE side. However, in `buildDefaultRelationFlatFieldMetadatasForCustomObject`, the destructuring `const { flatFieldMetadatas } = generateMorphOrRelationFlatFieldMetadataPair(...)` was silently discarding the `indexMetadatas` return value. **The fix** (2 files, ~10 lines changed): 1. **`build-default-relation-flat-field-metadatas-for-custom-object.util.ts`**: Added `standardRelationIndexMetadatas` to the accumulator record type. Now destructures `indexMetadatas` alongside `flatFieldMetadatas` and accumulates them across all default relation objects. 2. **`from-create-object-input-to-flat-object-metadata-and-flat-field-metadatas-to-create.util.ts`**: Spreads the new `standardRelationIndexMetadatas` into `flatIndexMetadataToCreate` alongside the existing search vector GIN index. **Why this is the right fix:** The index generation logic was already correct in `generateMorphOrRelationFlatFieldMetadataPair` (used successfully for user-created relation fields). The bug was purely that the custom object creation pipeline discarded the generated indexes. This was explicitly noted as a TODO in commit `fbd3286792` ("Index v2 side effects"): *"Will handle morph indexes in a new dedicated PR."* **Note for existing workspaces:** This fix only affects NEW custom object creation. Existing workspaces with custom objects will still have missing indexes on their standard object tables. A one-time migration or `workspace:sync-metadata` run would be needed to backfill those indexes for existing custom objects.
The #1 Open-Source CRM
🌐 Website · 📚 Documentation · Roadmap ·
Discord ·
Figma
Installation
See: 🚀 Self-hosting 🖥️ Local Setup
Why Twenty
We built Twenty for three reasons:
CRMs are too expensive, and users are trapped. Companies use locked-in customer data to hike prices. It shouldn't be that way.
A fresh start is required to build a better experience. We can learn from past mistakes and craft a cohesive experience inspired by new UX patterns from tools like Notion, Airtable or Linear.
We believe in open-source and community. Hundreds of developers are already building Twenty together. Once we have plugin capabilities, a whole ecosystem will grow around it.
What You Can Do With Twenty
Please feel free to flag any specific needs you have by creating an issue.
Below are a few features we have implemented to date:
- Personalize layouts with filters, sort, group by, kanban and table views
- Customize your objects and fields
- Create and manage permissions with custom roles
- Automate workflow with triggers and actions
- Emails, calendar events, files, and more
Personalize layouts with filters, sort, group by, kanban and table views
Customize your objects and fields
Create and manage permissions with custom roles
Automate workflow with triggers and actions
Emails, calendar events, files, and more
Stack
- TypeScript
- Nx
- NestJS, with BullMQ, PostgreSQL, Redis
- React, with Jotai, Linaria and Lingui
Thanks
Thanks to these amazing services that we use and recommend for UI testing (Chromatic), code review (Greptile), catching bugs (Sentry) and translating (Crowdin).
Join the Community
- Star the repo
- Subscribe to releases (watch -> custom -> releases)
- Follow us on Twitter or LinkedIn
- Join our Discord
- Improve translations on Crowdin
- Contributions are, of course, most welcome!




