Skip to content

Commit 958deab

Browse files
slaveeksCopilot
andauthored
Update migrations/20250911000000-add-timestamp-index-to-repetitions.js
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent d525d1f commit 958deab

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

migrations/20250911000000-add-timestamp-index-to-repetitions.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,13 @@ module.exports = {
6666
console.log(`${currentCollectionNumber} of ${targetCollections.length} in process.`);
6767

6868
try {
69-
await db.collection(collectionName).dropIndex(timestampIndexName);
70-
console.log(`Index ${timestampIndexName} dropped for ${collectionName}`);
69+
const hasIndexAlready = await db.collection(collectionName).indexExists(timestampIndexName);
70+
if (hasIndexAlready) {
71+
await db.collection(collectionName).dropIndex(timestampIndexName);
72+
console.log(`Index ${timestampIndexName} dropped for ${collectionName}`);
73+
} else {
74+
console.log(`Index ${timestampIndexName} does not exist for ${collectionName}, skipping drop.`);
75+
}
7176
} catch (error) {
7277
console.error(`Error dropping index from ${collectionName}:`, error);
7378
}

0 commit comments

Comments
 (0)