diff --git a/packages/hydrooj/src/upgrade.ts b/packages/hydrooj/src/upgrade.ts index de8afdc2c..1820ee9ab 100644 --- a/packages/hydrooj/src/upgrade.ts +++ b/packages/hydrooj/src/upgrade.ts @@ -620,9 +620,10 @@ const scripts: UpgradeScript[] = [ return await iterateAllDomain(async ({ _id }) => { const cursor = discussion.getMulti(_id, { parentType: document.TYPE_CONTEST }); for await (const ddoc of cursor) { - await discussion.edit(_id, ddoc.docId, { parentId: new ObjectId(ddoc.parentId) }); + const parentId = new ObjectId(ddoc.parentId); + await discussion.edit(_id, ddoc.docId, { parentId }); try { - await contest.get(_id, ddoc.parentId as ObjectId); + await contest.get(_id, parentId); } catch (e) { await discussion.del(_id, ddoc.docId); }