From 73963c89fc96fdfc1fdd9716ab2ef33b62a7d5f1 Mon Sep 17 00:00:00 2001 From: whyour Date: Sun, 6 Mar 2022 00:01:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=9B=B4=E6=96=B0=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E4=BB=BB=E5=8A=A12.11.3=E4=BB=A5=E5=89=8D=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/loaders/initData.ts | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/back/loaders/initData.ts b/back/loaders/initData.ts index 83407526..ba73bb9c 100644 --- a/back/loaders/initData.ts +++ b/back/loaders/initData.ts @@ -54,6 +54,56 @@ export default async () => { } }); + // 更新2.11.3以前的脚本路径 + CrontabModel.findAll({ + where: { + isDisabled: { [Op.ne]: 1 }, + command: { + [Op.or]: [ + { [Op.like]: `%\/ql\/scripts\/%` }, + { [Op.like]: `%\/ql\/config\/%` }, + { [Op.like]: `%\/ql\/log\/%` }, + { [Op.like]: `%\/ql\/db\/%` }, + ], + }, + }, + }).then(async (docs) => { + for (let i = 0; i < docs.length; i++) { + const doc = docs[i]; + if (doc) { + if (doc.command.includes('/ql/scripts/')) { + await CrontabModel.update( + { command: doc.command.replace('/ql/scripts/', '') }, + { where: { id: doc.id } }, + ); + } + if (doc.command.includes('/ql/log/')) { + await CrontabModel.update( + { command: `/ql/data/log/${doc.command.replace('/ql/log/', '')}` }, + { where: { id: doc.id } }, + ); + } + if (doc.command.includes('/ql/config/')) { + await CrontabModel.update( + { + command: `/ql/data/config/${doc.command.replace( + '/ql/config/', + '', + )}`, + }, + { where: { id: doc.id } }, + ); + } + if (doc.command.includes('/ql/db/')) { + await CrontabModel.update( + { command: `/ql/data/db/${doc.command.replace('/ql/db/', '')}` }, + { where: { id: doc.id } }, + ); + } + } + } + }); + // 初始化保存一次ck和定时任务数据 await cronService.autosave_crontab(); await envService.set_envs();