mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: better upgrade mode
This commit is contained in:
1 parent
aa096322c3
commit
a6297bfe9b
5 files changed
+26
-22
No files matched your search
+5
-5
@@ -21,10 +21,10 @@
|
||||
"@shelf/jest-mongodb": "^1.2.3",
|
||||
"@types/cross-spawn": "^6.0.2",
|
||||
"@types/jest": "^26.0.20",
|
||||
"@types/node": "^14.14.34",
|
||||
"@types/node": "^14.14.35",
|
||||
"@types/semver": "^7.3.4",
|
||||
"@typescript-eslint/eslint-plugin": "^4.17.0",
|
||||
"@typescript-eslint/parser": "^4.17.0",
|
||||
"@typescript-eslint/eslint-plugin": "^4.18.0",
|
||||
"@typescript-eslint/parser": "^4.18.0",
|
||||
"cross-spawn": "^7.0.3",
|
||||
"eslint": "^7.22.0",
|
||||
"eslint-config-airbnb-typescript": "^12.0.0",
|
||||
@@ -33,9 +33,9 @@
|
||||
"globby": "^11.0.2",
|
||||
"jest": "^26.6.3",
|
||||
"latest-version": "^5.1.0",
|
||||
"ora": "^5.3.0",
|
||||
"ora": "^5.4.0",
|
||||
"semver": "^7.3.4",
|
||||
"ts-jest": "^26.5.3",
|
||||
"ts-jest": "^26.5.4",
|
||||
"typescript": "4.2.3"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
"lodash": "^4.17.21",
|
||||
"p-queue": "^6.6.1",
|
||||
"shell-quote": "^1.7.2",
|
||||
"systeminformation": "5.6.4",
|
||||
"systeminformation": "5.6.7",
|
||||
"ws": "^7.4.4",
|
||||
"yargs": "^16.2.0"
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.20.23",
|
||||
"version": "2.20.24",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
@@ -27,14 +27,14 @@
|
||||
"lru-cache": "^6.0.0",
|
||||
"minio": "7.0.17",
|
||||
"moment-timezone": "^0.5.32",
|
||||
"mongodb": "^3.6.4",
|
||||
"mongodb": "^3.6.5",
|
||||
"nodemailer": "^6.5.0",
|
||||
"p-queue": "^6.6.2",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"serialize-javascript": "^5.0.1",
|
||||
"sockjs": "^0.3.20",
|
||||
"superagent": "^6.1.0",
|
||||
"systeminformation": "5.6.4",
|
||||
"systeminformation": "5.6.7",
|
||||
"wtfnode": "^0.8.4",
|
||||
"yargs": "^16.2.0"
|
||||
},
|
||||
|
||||
@@ -49,15 +49,19 @@ async function iterateAllProblem(
|
||||
}
|
||||
|
||||
const scripts: UpgradeScript[] = [
|
||||
// Init
|
||||
// Mark as used
|
||||
async function _0_1() {
|
||||
return true;
|
||||
},
|
||||
// Init
|
||||
async function _1_2() {
|
||||
const ddoc = await domain.get('system');
|
||||
if (!ddoc) await domain.add('system', 1, 'Hydro', 'Hydro System');
|
||||
// TODO discussion node?
|
||||
return true;
|
||||
},
|
||||
// Add history column to ddoc,drdoc,psdoc
|
||||
async function _1_2() {
|
||||
async function _2_3() {
|
||||
const _FRESH_INSTALL_IGNORE = 1;
|
||||
await iterateAllDomain(async (d) => {
|
||||
const bulk = document.coll.initializeUnorderedBulkOp();
|
||||
@@ -75,12 +79,12 @@ const scripts: UpgradeScript[] = [
|
||||
});
|
||||
return true;
|
||||
},
|
||||
async function _2_3() {
|
||||
async function _3_4() {
|
||||
const _FRESH_INSTALL_IGNORE = 1;
|
||||
await db.collection('document').updateMany({ pid: /^\d+$/i }, { $unset: { pid: '' } });
|
||||
return true;
|
||||
},
|
||||
async function _3_4() {
|
||||
async function _4_5() {
|
||||
const _FRESH_INSTALL_IGNORE = 1;
|
||||
if (storage.error) {
|
||||
logger.error('Cannot upgrade. Please change storage config.');
|
||||
@@ -131,7 +135,7 @@ const scripts: UpgradeScript[] = [
|
||||
logger.success('Files copied successfully. You can now remove collection `file` `fs.files` `fs.chunks` in the database.');
|
||||
return true;
|
||||
},
|
||||
async function _4_5() {
|
||||
async function _5_6() {
|
||||
const _FRESH_INSTALL_IGNORE = 1;
|
||||
await iterateAllDomain(async (d) => {
|
||||
const bulk = document.coll.initializeUnorderedBulkOp();
|
||||
@@ -144,16 +148,16 @@ const scripts: UpgradeScript[] = [
|
||||
});
|
||||
return true;
|
||||
},
|
||||
async function _5_6() {
|
||||
async function _6_7() {
|
||||
// Issue #58
|
||||
const _FRESH_INSTALL_IGNORE = 1;
|
||||
await domain.edit('system', { owner: 1 });
|
||||
return true;
|
||||
},
|
||||
async function _6_7() {
|
||||
async function _7_8() {
|
||||
return true; // invalid
|
||||
},
|
||||
async function _7_8() {
|
||||
async function _8_9() {
|
||||
const _FRESH_INSTALL_IGNORE = 1;
|
||||
await iterateAllProblem(['docId', 'domainId', 'config'], async (pdoc) => {
|
||||
logger.info('%s/%s', pdoc.domainId, pdoc.docId);
|
||||
@@ -169,7 +173,7 @@ const scripts: UpgradeScript[] = [
|
||||
});
|
||||
return true;
|
||||
},
|
||||
async function _8_9() {
|
||||
async function _9_10() {
|
||||
const _FRESH_INSTALL_IGNORE = 1;
|
||||
await iterateAllProblem([], async (pdoc) => {
|
||||
logger.info('%s/%s', pdoc.domainId, pdoc.docId);
|
||||
@@ -188,7 +192,7 @@ const scripts: UpgradeScript[] = [
|
||||
return true;
|
||||
},
|
||||
// Move category to tag
|
||||
async function _9_10() {
|
||||
async function _10_11() {
|
||||
const _FRESH_INSTALL_IGNORE = 1;
|
||||
await iterateAllProblem(['tag', 'category'], async (pdoc) => {
|
||||
await document.coll.updateOne(
|
||||
@@ -202,13 +206,13 @@ const scripts: UpgradeScript[] = [
|
||||
return true;
|
||||
},
|
||||
// Set null tag to []
|
||||
async function _10_11() {
|
||||
async function _11_12() {
|
||||
const _FRESH_INSTALL_IGNORE = 1;
|
||||
await db.collection('document').updateMany({ docType: 10, tag: null }, { $set: { tag: [] } });
|
||||
return true;
|
||||
},
|
||||
// Update problem difficulty
|
||||
async function _11_12() {
|
||||
async function _12_13() {
|
||||
const _FRESH_INSTALL_IGNORE = 1;
|
||||
await iterateAllProblem(['nSubmit', 'nAccept'], async (pdoc) => {
|
||||
const difficulty = difficultyAlgorithm(pdoc.nSubmit, pdoc.nAccept);
|
||||
|
||||
@@ -16,6 +16,6 @@
|
||||
"hydrooj": "^2.17.22"
|
||||
},
|
||||
"dependencies": {
|
||||
"mongodb": "^3.6.4"
|
||||
"mongodb": "^3.6.5"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user