Add ALTER TABLE statements for userId columns in db.ts

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-11-10 16:57:18 +00:00
parent d42074f76a
commit bf9be821ba

View File

@ -6,6 +6,7 @@ import { AppModel } from '../data/open';
import { SystemModel } from '../data/system';
import { SubscriptionModel } from '../data/subscription';
import { CrontabViewModel } from '../data/cronView';
import { UserModel } from '../data/user';
import { sequelize } from '../data';
export default async () => {
@ -17,6 +18,7 @@ export default async () => {
await EnvModel.sync();
await SubscriptionModel.sync();
await CrontabViewModel.sync();
await UserModel.sync();
// 初始化新增字段
try {
@ -64,6 +66,20 @@ export default async () => {
try {
await sequelize.query('alter table Envs add column isPinned NUMBER');
} catch (error) {}
// Multi-user support: Add userId columns
try {
await sequelize.query('alter table Crontabs add column userId NUMBER');
} catch (error) {}
try {
await sequelize.query('alter table Envs add column userId NUMBER');
} catch (error) {}
try {
await sequelize.query('alter table Subscriptions add column userId NUMBER');
} catch (error) {}
try {
await sequelize.query('alter table Dependences add column userId NUMBER');
} catch (error) {}
Logger.info('✌️ DB loaded');
} catch (error) {