Skip to content
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

Merged
merged 2 commits into from
Sep 20, 2024
Merged

Conversation

Weiko
Copy link
Member

@Weiko Weiko commented Sep 19, 2024

TODO: command to retro-actively create indexes to existing custom objects

Copy link
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.

PR Summary

This pull request adds functionality to create indexes for custom relations in the Twenty application.

  • Introduced new IndexMetadataService in index-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 export IndexMetadataService
  • Integrated IndexMetadataModule into RelationMetadataModule for handling index operations on custom relations

4 file(s) reviewed, 4 comment(s)
Edit PR Review Bot Settings

Comment on lines 34 to 36
const columnNames: string[] = Array.from(fieldMetadataToIndexSet).map(
(fieldMetadata) => fieldMetadata.name as string,
);
Copy link
Contributor

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

Comment on lines +63 to +67
if (!savedIndexMetadata) {
throw new Error(
`Failed to return saved index ${indexName} on object metadata ${objectMetadata.nameSingular}`,
);
}
Copy link
Contributor

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

Comment on lines +133 to +138
if (!foreignKeyFieldMetadata) {
throw new RelationMetadataException(
`ForeignKey field metadata not found`,
RelationMetadataExceptionCode.RELATION_METADATA_NOT_FOUND,
);
}
Copy link
Contributor

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

Comment on lines +145 to +150
if (!deletedFieldMetadata) {
throw new RelationMetadataException(
`Deleted field metadata not found`,
RelationMetadataExceptionCode.RELATION_METADATA_NOT_FOUND,
);
}
Copy link
Contributor

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

@Weiko Weiko enabled auto-merge (squash) September 20, 2024 13:05
Copy link
Collaborator

@ijreilly ijreilly left a comment

Choose a reason for hiding this comment

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

excellent work.

@Weiko Weiko merged commit bebeb15 into main Sep 20, 2024
8 checks passed
@Weiko Weiko deleted the c--add-index-to-custom-relations branch September 20, 2024 13:06
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.

2 participants