mirror of
https://github.com/whyour/qinglong.git
synced 2025-11-10 00:26:09 +08:00
* Initial plan * Add log_name field to enable custom log folder naming Co-authored-by: whyour <22700758+whyour@users.noreply.github.com> * Add database migration for log_name column Co-authored-by: whyour <22700758+whyour@users.noreply.github.com> * Add security validation to prevent path traversal attacks Co-authored-by: whyour <22700758+whyour@users.noreply.github.com> * Apply prettier formatting to modified files Co-authored-by: whyour <22700758+whyour@users.noreply.github.com> * Support absolute paths like /dev/null for log redirection Co-authored-by: whyour <22700758+whyour@users.noreply.github.com> * Restrict absolute paths to log directory except /dev/null Co-authored-by: whyour <22700758+whyour@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
70 lines
2.0 KiB
TypeScript
70 lines
2.0 KiB
TypeScript
import Logger from './logger';
|
|
import { EnvModel } from '../data/env';
|
|
import { CrontabModel } from '../data/cron';
|
|
import { DependenceModel } from '../data/dependence';
|
|
import { AppModel } from '../data/open';
|
|
import { SystemModel } from '../data/system';
|
|
import { SubscriptionModel } from '../data/subscription';
|
|
import { CrontabViewModel } from '../data/cronView';
|
|
import { sequelize } from '../data';
|
|
|
|
export default async () => {
|
|
try {
|
|
await CrontabModel.sync();
|
|
await DependenceModel.sync();
|
|
await AppModel.sync();
|
|
await SystemModel.sync();
|
|
await EnvModel.sync();
|
|
await SubscriptionModel.sync();
|
|
await CrontabViewModel.sync();
|
|
|
|
// 初始化新增字段
|
|
try {
|
|
await sequelize.query(
|
|
'alter table CrontabViews add column filterRelation VARCHAR(255)',
|
|
);
|
|
} catch (error) {}
|
|
try {
|
|
await sequelize.query(
|
|
'alter table Subscriptions add column proxy VARCHAR(255)',
|
|
);
|
|
} catch (error) {}
|
|
try {
|
|
await sequelize.query('alter table CrontabViews add column type NUMBER');
|
|
} catch (error) {}
|
|
try {
|
|
await sequelize.query(
|
|
'alter table Subscriptions add column autoAddCron NUMBER',
|
|
);
|
|
} catch (error) {}
|
|
try {
|
|
await sequelize.query(
|
|
'alter table Subscriptions add column autoDelCron NUMBER',
|
|
);
|
|
} catch (error) {}
|
|
try {
|
|
await sequelize.query('alter table Crontabs add column sub_id NUMBER');
|
|
} catch (error) {}
|
|
try {
|
|
await sequelize.query(
|
|
'alter table Crontabs add column extra_schedules JSON',
|
|
);
|
|
} catch (error) {}
|
|
try {
|
|
await sequelize.query('alter table Crontabs add column task_before TEXT');
|
|
} catch (error) {}
|
|
try {
|
|
await sequelize.query('alter table Crontabs add column task_after TEXT');
|
|
} catch (error) {}
|
|
try {
|
|
await sequelize.query(
|
|
'alter table Crontabs add column log_name VARCHAR(255)',
|
|
);
|
|
} catch (error) {}
|
|
|
|
Logger.info('✌️ DB loaded');
|
|
} catch (error) {
|
|
Logger.error('✌️ DB load failed', error);
|
|
}
|
|
};
|