修复数据库迁移版本冲突,成功添加 comfyui_prompt_id 字段

- 修复迁移版本号冲突:将 ComfyUI prompt_id 字段迁移从 v28 改为 v29
- 在 Cargo.toml 中添加 default-run 配置,解决 Tauri 开发命令的二进制文件选择问题
- 添加数据库检查工具 check_db.rs 用于调试数据库结构
- 成功应用迁移 v29,outfit_image_records 表现在包含 comfyui_prompt_id 字段
- 为解决批量任务进度更新错乱问题奠定基础
This commit is contained in:
imeepos 2025-07-31 15:41:15 +08:00
parent 59c7cb47ad
commit 833cb0d987
3 changed files with 69 additions and 2 deletions

View File

@ -4,6 +4,7 @@ version = "0.2.1"
description = "MixVideo Desktop Application"
authors = ["imeepos <imeepos@outlook.com>"]
edition = "2021"
default-run = "mixvideo-desktop"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -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<String>>(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(())
}

View File

@ -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, // 暂时不提供回滚脚本