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: ""}})
這也將失敗。
什麼是正確的方法?