-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add indexes to custom relations #7156
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This pull request adds functionality to create indexes for custom relations in the Twenty application.
- Introduced new
IndexMetadataService
inindex-metadata.service.ts
for managing index creation and metadata - Modified
RelationMetadataService
to create indexes on foreign key and deleted fields when new relations are created - Updated
IndexMetadataModule
to provide and exportIndexMetadataService
- Integrated
IndexMetadataModule
intoRelationMetadataModule
for handling index operations on custom relations
4 file(s) reviewed, 4 comment(s)
Edit PR Review Bot Settings
const columnNames: string[] = Array.from(fieldMetadataToIndexSet).map( | ||
(fieldMetadata) => fieldMetadata.name as string, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Unnecessary use of Array.from() on fieldMetadataToIndexSet which is already an array
if (!savedIndexMetadata) { | ||
throw new Error( | ||
`Failed to return saved index ${indexName} on object metadata ${objectMetadata.nameSingular}`, | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: This check might be redundant as the save operation would throw an error if it failed
if (!foreignKeyFieldMetadata) { | ||
throw new RelationMetadataException( | ||
`ForeignKey field metadata not found`, | ||
RelationMetadataExceptionCode.RELATION_METADATA_NOT_FOUND, | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Check if foreignKeyFieldMetadata exists before proceeding
if (!deletedFieldMetadata) { | ||
throw new RelationMetadataException( | ||
`Deleted field metadata not found`, | ||
RelationMetadataExceptionCode.RELATION_METADATA_NOT_FOUND, | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Check if deletedFieldMetadata exists before proceeding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
excellent work.
TODO: command to retro-actively create indexes to existing custom objects