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

Fix custom index creation missing indexFieldMetadatas #7832

Merged
merged 1 commit into from
Oct 18, 2024

Conversation

Weiko
Copy link
Member

@Weiko Weiko commented Oct 18, 2024

Context

Regression on custom index creation where indexFieldMetadatas were not saved properly in the DB. This is because we recently changed save() to upsert() in the indexMetadataService and upsert does not handle nesting insert properly.
I'm suggesting another fix where we separate indexMetadata creation and index migration creation in 2 different functions. Since the goal was to be able to recreate the index after being deleted when we changed the tsvector expression and indexMetadata was actually not deleted, we didn't need to recreate that part (hence the upsert) and only needed to run a migration to create the actual index in the workspace schema.
I've updated the different services and now only call createIndexMigration when we update a search vector expression.

Note: this is also fixing the sync-metadata command when running on a workspace with a custom object (including the seeded workspace which has the 'rocket' custom object), failing due to the missing 'searchVector' indexFieldMetadata

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 addresses a regression in custom index creation, focusing on properly saving indexFieldMetadatas in the database. Key changes include:

  • Separated index metadata creation and index migration creation into distinct functions in index-metadata.service.ts
  • Updated createIndexMetadata method to include error handling and checks for existing indexes
  • Modified relation-metadata.service.ts to use the new createIndexMetadata method
  • Refactored search.service.ts to utilize the updated IndexMetadataService methods
  • Improved handling of index recreation after deletion when updating tsvector expressions

These changes aim to resolve issues with nested inserts and ensure proper index creation and management across the codebase.

3 file(s) reviewed, 7 comment(s)
Edit PR Review Bot Settings | Greptile

@@ -157,7 +157,7 @@ export class SearchService {
);

// index needs to be recreated as typeorm deletes then recreates searchVector column at alter
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider moving this comment to the migration creation method for better context

@charlesBochet charlesBochet merged commit d4457d7 into main Oct 18, 2024
8 checks passed
@charlesBochet charlesBochet deleted the c--fix-custom-index-creation branch October 18, 2024 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants