fix: skip getIndexes() on non-existent collection during --dry-run

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-01 12:15:12 +03:00
parent 58a3251b8a
commit b883cc3db3

View File

@@ -57,8 +57,10 @@ for (const [collName, indexes] of Object.entries(data)) {
}
}
const existingIndexes = targetDb.getCollection(collName).getIndexes()
.filter(idx => idx.name !== "_id_");
const collectionExists = existingCollections.has(collName);
const existingIndexes = collectionExists
? targetDb.getCollection(collName).getIndexes().filter(idx => idx.name !== "_id_")
: [];
if (existingIndexes.length > 0) {
if (dryRun) {