Skip to content

docs(schema): clarify duplicate index warning to note index is not created (gh-16476) - #16478

Merged
vkarpov15 merged 1 commit into
Automattic:masterfrom
vjymisal0:fix/duplicate-index-warning-message
Aug 25, 2026
Merged

vkarpov15 merged 1 commit into
Automattic:masterfrom
vjymisal0:fix/duplicate-index-warning-message

Conversation

@vjymisal0

Copy link
Copy Markdown
Contributor

Summary

Clarifies the duplicate index warning in lib/model.js to explicitly state that MongoDB does not create duplicate indexes, and options on the duplicate definition (such as expireAfterSeconds or unique) will not be applied (gh-16476).

Fixes #16476

Examples

When declaring a duplicate index on the same path using both { index: true } and schema.index():

Before:

mongoose: Duplicate schema index on {"at":1} for model "Census". This is often due to declaring an index using both "index: true" and "schema.index()". Please remove the duplicate index definition.

After:

mongoose: Duplicate schema index on {"at":1} for model "Census". This is often due to declaring an index using both "index: true" and "schema.index()". MongoDB will not create the duplicate index and options on the duplicate definition (such as expireAfterSeconds or unique) will not be applied. Please remove the duplicate index definition.

@vkarpov15 vkarpov15 added this to the 9.9.4 milestone Aug 25, 2026

@vkarpov15 vkarpov15 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks 👍

@vkarpov15
vkarpov15 merged commit e57f554 into Automattic:master Aug 25, 2026
25 checks passed
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.

Duplicate index warning does not say the duplicate is never created

2 participants