Repository navigation
fix(data): stop rebuilding indexes declared with unique: false, hidden: false or a simple collation - #470
Merged
omegascorp merged 1 commit intoNov 16, 2026
Conversation
…n: false or a simple collation MongoDB leaves these out of the stored index, so the declared index never matched and was dropped and rebuilt on every startup.
omegascorp
approved these changes
Nov 16, 2026
omegascorp
left a comment
Collaborator
There was a problem hiding this comment.
Looks good, thank you for the PR poojagosika
This was referenced Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #469
MongoDB leaves
unique: false,hidden: falseand asimplecollation out of the stored index, soisSameIndexDefinitionnever matched andcreateIndexesdropped and rebuilt those indexes on every startup.falseforunique/hiddennow matches when the stored index omits it.simplecollation now matches a stored index with no collation.unique: trueor a real collation still rebuilds it. The first fails without the fix.Checked against MongoDB 7: before, the second startup dropped both indexes; after, nothing is dropped
Note
Low Risk
Changes are limited to index comparison logic in
createIndexes, with tests covering both the no-op and rebuild paths; no auth or data mutation behavior is affected.Overview
Index reconciliation now treats MongoDB’s omitted stored options as equivalent to explicit
falseorsimplecollation in code-defined indexes, socreateIndexesno longer drops and rebuilds those indexes on every startup.isSameCollationtreats a missing stored collation as matching a declared{ locale: 'simple' }.isSameIndexDefinitionignoresunique: falseandhidden: falseon the desired index when the server metadata omits those fields.Tests confirm unchanged indexes are kept when
listIndexesomits those options, and that addingunique: trueor a non-simple collation still triggers a rebuild.Reviewed by Cursor Bugbot for commit 8901175. Bugbot is set up for automated code reviews on this repo. Configure here.