Fix: Add ScenarioModel sync to database loader and migration for status column

- Import and sync ScenarioModel in back/loaders/db.ts
- Add migration to ensure 'status' column exists in Scenarios table
- Fixes SQLITE_ERROR: table Scenarios has no column named status

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-11-23 06:12:21 +00:00
parent 95780bd3ad
commit e1b903b6db

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 { ScenarioModel } from '../data/scenario';
import { sequelize } from '../data';
export default async () => {
@ -17,6 +18,7 @@ export default async () => {
await EnvModel.sync();
await SubscriptionModel.sync();
await CrontabViewModel.sync();
await ScenarioModel.sync();
// 初始化新增字段
const migrations = [
@ -40,6 +42,7 @@ export default async () => {
type: 'NUMBER',
},
{ table: 'Envs', column: 'isPinned', type: 'NUMBER' },
{ table: 'Scenarios', column: 'status', type: 'INTEGER DEFAULT 0' },
];
for (const migration of migrations) {