I have the same problem as in this question :
MongoDB dump from 3.2, restore with 3.4, error index save = null
In my case, recreating indexes by hand is not an option, I need a script that automates this for migrating my production environment later.
What I have tried so far :
1/ running this in mongo shell on the new database:
for (var collection in ["_tempstore", "contracts", "images", "thumbs", "covers", "invoices"]) {
db.getCollection("cfs_gridfs." + collection + ".files").createIndex({filename: 1});
db.getCollection("cfs_gridfs." + collection + ".chunks").createIndex({files_id: 1, n: 1});
}
which fails.
2/ Getting rid of the extraneous w
key which is the root of the issue in my indexes on my old database by running :
db.system.indexes.update({w: {$exists: true}}, {$unset: {w: ""}})
which also fails.
What is the correct way to proceed?