0
我有同样的问题,在这个问题:从蒙戈3.2附加键迁移索引MONGO 3.4
MongoDB dump from 3.2, restore with 3.4, error index save = null
在我的情况,由专人重新创建索引是不是一种选择,我需要一个脚本将其自动化,以便稍后迁移我的生产环境。
我迄今为止尝试:
1 /新数据库在蒙戈外壳运行以下命令:
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});
}
其失败。
2 /快速运行摆脱外来w
关键这是我在我的旧数据库索引问题的根源:
db.system.indexes.update({w: {$exists: true}}, {$unset: {w: ""}})
这也将失败。
什么是正确的方法?