diff --git a/src/lib/fixDB.ts b/src/lib/fixDB.ts index 31dce79..7d06c60 100644 --- a/src/lib/fixDB.ts +++ b/src/lib/fixDB.ts @@ -1,5 +1,5 @@ import { Knex } from "knex"; - +import db from "@/utils/db"; export default async (knex: Knex): Promise => { const addColumn = async (table: string, column: string, type: string) => { if (!(await knex.schema.hasTable(table))) return; @@ -23,4 +23,28 @@ export default async (knex: Knex): Promise => { }); } }; + 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: "软件退出导致失败", + }); }; diff --git a/src/types/database.d.ts b/src/types/database.d.ts index dc02b6a..1af96b9 100644 --- a/src/types/database.d.ts +++ b/src/types/database.d.ts @@ -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 { 'content': string; 'createTime': number; @@ -247,7 +231,6 @@ export interface o_videoTrack { } export interface DB { - "_o_project_old_20260404": _o_project_old_20260404; "memories": memories; "o_agentDeploy": o_agentDeploy; "o_agentWorkData": o_agentWorkData; diff --git a/src/utils/db.ts b/src/utils/db.ts index 58522b5..ab4bb69 100644 --- a/src/utils/db.ts +++ b/src/utils/db.ts @@ -7,6 +7,7 @@ import initDB from "@/lib/initDB"; // import fixDB from "@/lib/fixDB"; import type { DB } from "@/types/database"; import crypto from "crypto"; +import fixDB from "@/lib/fixDB"; type TableName = keyof DB & string; type RowType = DB[TName]; @@ -35,7 +36,7 @@ const db = knex({ (async () => { await initDB(db); - // await fixDB(db); + await fixDB(db); if (process.env.NODE_ENV == "dev") initKnexType(db); })();