core: fix document.status unique key

This commit is contained in:
undefined committed 2021-07-25 21:50:41 +08:00
1 parent 08585bd3e9
commit b4d77d3a2a
5 files changed
+16 -4

No files matched your search

+1 -1
View File
@@ -404,7 +404,7 @@ export async function revSetStatus<T extends keyof DocStatusType>(
async function ensureIndexes() {
const ic = coll.createIndex.bind(coll);
const is = collStatus.createIndex.bind(coll);
const is = collStatus.createIndex.bind(collStatus);
const u = { unique: true };
const s = { sparse: true };
await ic({ domainId: 1, docType: 1, docId: 1 }, u);
+12
View File
@@ -402,6 +402,18 @@ const scripts: UpgradeScript[] = [
await RecordModel.coll.updateMany({}, { $unset: { effective: '' } });
return true;
},
async function _36_37() {
const _FRESH_INSTALL_IGNORE = 1;
const cur = document.collStatus.find();
while (await cur.hasNext()) {
const doc = await cur.next();
await document.collStatus.deleteMany({
...pick(doc, ['docId', 'domainId', 'uid', 'docType']),
_id: { $gt: doc._id },
});
}
return true;
},
];
export default scripts;