mirror of
https://github.com/whyour/qinglong.git
synced 2025-12-16 09:15:38 +08:00
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:
parent
d42074f76a
commit
bf9be821ba
|
|
@ -6,6 +6,7 @@ import { AppModel } from '../data/open';
|
||||||
import { SystemModel } from '../data/system';
|
import { SystemModel } from '../data/system';
|
||||||
import { SubscriptionModel } from '../data/subscription';
|
import { SubscriptionModel } from '../data/subscription';
|
||||||
import { CrontabViewModel } from '../data/cronView';
|
import { CrontabViewModel } from '../data/cronView';
|
||||||
|
import { UserModel } from '../data/user';
|
||||||
import { sequelize } from '../data';
|
import { sequelize } from '../data';
|
||||||
|
|
||||||
export default async () => {
|
export default async () => {
|
||||||
|
|
@ -17,6 +18,7 @@ export default async () => {
|
||||||
await EnvModel.sync();
|
await EnvModel.sync();
|
||||||
await SubscriptionModel.sync();
|
await SubscriptionModel.sync();
|
||||||
await CrontabViewModel.sync();
|
await CrontabViewModel.sync();
|
||||||
|
await UserModel.sync();
|
||||||
|
|
||||||
// 初始化新增字段
|
// 初始化新增字段
|
||||||
try {
|
try {
|
||||||
|
|
@ -65,6 +67,20 @@ export default async () => {
|
||||||
await sequelize.query('alter table Envs add column isPinned NUMBER');
|
await sequelize.query('alter table Envs add column isPinned NUMBER');
|
||||||
} catch (error) {}
|
} 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');
|
Logger.info('✌️ DB loaded');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Logger.error('✌️ DB load failed', error);
|
Logger.error('✌️ DB load failed', error);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user