Index specifications changed silently after upgrading Mongoose from 6.x to 7.x
0 reputation · 03 May 2026, 00:18 UTC
Unexpected index behavior after a Mongoose upgrade
A Node.js service using Mongoose for data access was recently upgraded from version 6.x to 7.x, with no changes to schema definitions or index declarations. After deployment, the index specifications on several collections no longer match what the same code produced under Mongoose 6.
Documentation and migration notes indicate that Mongoose 7 changed the default value of the useCreateIndex connection option to true, whereas Mongoose 6 defaulted it to false. Code written against v6 may therefore rely on the old default without ever setting the option explicitly.
Constraints and uncertainty
- The option was never set in the codebase, so behavior depends entirely on the version-specific default.
- It is unclear whether toggling the option back affects indexes that were already created, or whether a full reindex is required.
- The goal is to confirm the root cause from observable state (installed version, generated indexes) rather than assumptions, and to decide whether to pin the option explicitly or rebuild indexes.
Assuming Mongoose 7.x, what is the reliable way to verify that the useCreateIndex default change is responsible for the differing index specifications? Does reverting the option to false restore prior behavior for existing collections, or must indexes be dropped and recreated? Are there other v6-to-v7 default changes that could produce similar silent drift?