From b883cc3db3523f0eb38e728cf7087af8b7e01826 Mon Sep 17 00:00:00 2001 From: pronchev Date: Wed, 1 Apr 2026 12:15:12 +0300 Subject: [PATCH] fix: skip getIndexes() on non-existent collection during --dry-run Co-Authored-By: Claude Sonnet 4.6 --- import-indexes.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/import-indexes.sh b/import-indexes.sh index c4b8f04..39150a9 100755 --- a/import-indexes.sh +++ b/import-indexes.sh @@ -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) {