From 833cb0d987c83b3bb1b8cb461ab1d61c864fd8a1 Mon Sep 17 00:00:00 2001 From: imeepos Date: Thu, 31 Jul 2025 15:41:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E8=BF=81=E7=A7=BB=E7=89=88=E6=9C=AC=E5=86=B2=E7=AA=81=EF=BC=8C?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E6=B7=BB=E5=8A=A0=20comfyui=5Fprompt=5Fid=20?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复迁移版本号冲突:将 ComfyUI prompt_id 字段迁移从 v28 改为 v29 - 在 Cargo.toml 中添加 default-run 配置,解决 Tauri 开发命令的二进制文件选择问题 - 添加数据库检查工具 check_db.rs 用于调试数据库结构 - 成功应用迁移 v29,outfit_image_records 表现在包含 comfyui_prompt_id 字段 - 为解决批量任务进度更新错乱问题奠定基础 --- apps/desktop/src-tauri/Cargo.toml | 1 + apps/desktop/src-tauri/src/bin/check_db.rs | 66 +++++++++++++++++++ .../src/infrastructure/database/migrations.rs | 4 +- 3 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 apps/desktop/src-tauri/src/bin/check_db.rs diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.toml index 50e43aa..7394dc2 100644 --- a/apps/desktop/src-tauri/Cargo.toml +++ b/apps/desktop/src-tauri/Cargo.toml @@ -4,6 +4,7 @@ version = "0.2.1" description = "MixVideo Desktop Application" authors = ["imeepos "] edition = "2021" +default-run = "mixvideo-desktop" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/apps/desktop/src-tauri/src/bin/check_db.rs b/apps/desktop/src-tauri/src/bin/check_db.rs new file mode 100644 index 0000000..ac90ce0 --- /dev/null +++ b/apps/desktop/src-tauri/src/bin/check_db.rs @@ -0,0 +1,66 @@ +use rusqlite::{Connection, Result}; +use std::path::PathBuf; + +fn main() -> Result<()> { + // 获取数据库路径 + let app_data_dir = dirs::data_dir() + .expect("无法获取应用数据目录") + .join("mixvideo"); + + let db_path = app_data_dir.join("mixvideoV2.db"); + + println!("数据库路径: {}", db_path.display()); + + if !db_path.exists() { + println!("数据库文件不存在"); + return Ok(()); + } + + // 连接数据库 + let conn = Connection::open(&db_path)?; + + // 检查 outfit_image_records 表结构 + println!("\n=== outfit_image_records 表结构 ==="); + let mut stmt = conn.prepare("PRAGMA table_info(outfit_image_records)")?; + let rows = stmt.query_map([], |row| { + Ok(( + row.get::<_, i32>(0)?, // cid + row.get::<_, String>(1)?, // name + row.get::<_, String>(2)?, // type + row.get::<_, i32>(3)?, // notnull + row.get::<_, Option>(4)?, // dflt_value + row.get::<_, i32>(5)?, // pk + )) + })?; + + for row in rows { + let (cid, name, type_, notnull, dflt_value, pk) = row?; + println!("{}: {} {} {} {} {}", cid, name, type_, notnull, dflt_value.unwrap_or("NULL".to_string()), pk); + } + + // 检查迁移历史 + println!("\n=== 迁移历史 ==="); + let mut stmt = conn.prepare("SELECT version, description, applied_at, success FROM schema_migrations ORDER BY version")?; + let rows = stmt.query_map([], |row| { + Ok(( + row.get::<_, u32>(0)?, // version + row.get::<_, String>(1)?, // description + row.get::<_, String>(2)?, // applied_at + row.get::<_, i32>(3)?, // success + )) + })?; + + for row in rows { + let (version, description, applied_at, success) = row?; + println!("v{}: {} - {} (成功: {})", version, description, applied_at, success == 1); + } + + // 检查是否有 comfyui_prompt_id 字段 + println!("\n=== 检查 comfyui_prompt_id 字段 ==="); + match conn.prepare("SELECT comfyui_prompt_id FROM outfit_image_records LIMIT 1") { + Ok(_) => println!("✅ comfyui_prompt_id 字段存在"), + Err(e) => println!("❌ comfyui_prompt_id 字段不存在: {}", e), + } + + Ok(()) +} diff --git a/apps/desktop/src-tauri/src/infrastructure/database/migrations.rs b/apps/desktop/src-tauri/src/infrastructure/database/migrations.rs index 99653ad..c82c1da 100644 --- a/apps/desktop/src-tauri/src/infrastructure/database/migrations.rs +++ b/apps/desktop/src-tauri/src/infrastructure/database/migrations.rs @@ -262,9 +262,9 @@ impl MigrationManager { down_sql: Some(include_str!("migrations/027_create_video_generation_records_table_down.sql").to_string()), }); - // 迁移 28: 添加 ComfyUI prompt_id 字段到穿搭图片生成记录表 + // 迁移 29: 添加 ComfyUI prompt_id 字段到穿搭图片生成记录表 self.add_migration(Migration { - version: 28, + version: 29, description: "添加 ComfyUI prompt_id 字段到穿搭图片生成记录表".to_string(), up_sql: include_str!("migrations/028_add_comfyui_prompt_id_to_outfit_image_records.sql").to_string(), down_sql: None, // 暂时不提供回滚脚本