增加 生成中状态 在软件重启时 改为失败

This commit is contained in:
zhishi 2026-04-06 22:15:13 +08:00
parent e7eb679252
commit 92a3af229d
3 changed files with 28 additions and 20 deletions

View File

@ -1,5 +1,5 @@
import { Knex } from "knex"; import { Knex } from "knex";
import db from "@/utils/db";
export default async (knex: Knex): Promise<void> => { export default async (knex: Knex): Promise<void> => {
const addColumn = async (table: string, column: string, type: string) => { const addColumn = async (table: string, column: string, type: string) => {
if (!(await knex.schema.hasTable(table))) return; if (!(await knex.schema.hasTable(table))) return;
@ -23,4 +23,28 @@ export default async (knex: Knex): Promise<void> => {
}); });
} }
}; };
await db("o_novel").where("eventState", 0).update({
eventState: -1,
errorReason: "软件退出导致失败",
});
await db("o_script").where("extractState", 0).update({
extractState: -1,
errorReason: "软件退出导致失败",
});
await db("o_assets").where("promptState", "生成中").update({
promptState: "生成失败",
promptErrorReason: "软件退出导致失败",
});
await db("o_image").where("state", "生成中").update({
state: "生成失败",
errorReason: "软件退出导致失败",
});
await db("o_storyboard").where("state", "生成中").update({
state: "生成失败",
reason: "软件退出导致失败",
});
await db("o_video").where("state", "生成中").update({
state: "生成失败",
errorReason: "软件退出导致失败",
});
}; };

View File

@ -1,22 +1,6 @@
// @db-hash 19c726e36479d905346c772cfa8007ba // @db-hash 6fa5017e455bc367c9c902ba574d11b4
//该文件由脚本自动生成,请勿手动修改 //该文件由脚本自动生成,请勿手动修改
export interface _o_project_old_20260404 {
'artStyle'?: string | null;
'createTime'?: number | null;
'directorManual'?: string | null;
'id'?: number | null;
'imageModel'?: string | null;
'imageQuality'?: string | null;
'intro'?: string | null;
'mode'?: string | null;
'name'?: string | null;
'projectType'?: string | null;
'type'?: string | null;
'userId'?: number | null;
'videoModel'?: string | null;
'videoRatio'?: string | null;
}
export interface memories { export interface memories {
'content': string; 'content': string;
'createTime': number; 'createTime': number;
@ -247,7 +231,6 @@ export interface o_videoTrack {
} }
export interface DB { export interface DB {
"_o_project_old_20260404": _o_project_old_20260404;
"memories": memories; "memories": memories;
"o_agentDeploy": o_agentDeploy; "o_agentDeploy": o_agentDeploy;
"o_agentWorkData": o_agentWorkData; "o_agentWorkData": o_agentWorkData;

View File

@ -7,6 +7,7 @@ import initDB from "@/lib/initDB";
// import fixDB from "@/lib/fixDB"; // import fixDB from "@/lib/fixDB";
import type { DB } from "@/types/database"; import type { DB } from "@/types/database";
import crypto from "crypto"; import crypto from "crypto";
import fixDB from "@/lib/fixDB";
type TableName = keyof DB & string; type TableName = keyof DB & string;
type RowType<TName extends TableName> = DB[TName]; type RowType<TName extends TableName> = DB[TName];
@ -35,7 +36,7 @@ const db = knex({
(async () => { (async () => {
await initDB(db); await initDB(db);
// await fixDB(db); await fixDB(db);
if (process.env.NODE_ENV == "dev") initKnexType(db); if (process.env.NODE_ENV == "dev") initKnexType(db);
})(); })();