【修复】修复首次安装报错的问题

pull/295/head
v-me-50 2025-07-18 11:31:17 +08:00
parent 80e8c09c2b
commit 4fd115dfb1
1 changed files with 6 additions and 6 deletions

View File

@ -116,14 +116,14 @@ func MigrateSQLiteTable(sourceDBPath, sourceTable, targetDBPath, targetTable str
// 创建目标表 // 创建目标表
//fmt.Printf("目标表 %s 不存在,正在创建...\n", targetTable) //fmt.Printf("目标表 %s 不存在,正在创建...\n", targetTable)
if _, err := targetDB.Exec(createTableSQL); err != nil { if _, err := targetDB.Exec(createTableSQL); err != nil {
//return fmt.Errorf("创建目标表失败: %v", err) return fmt.Errorf("创建目标表失败: %v", err)
} }
fmt.Printf("目标表 %s 创建成功。\n", targetTable) fmt.Printf("目标表 %s 创建成功。\n", targetTable)
// 打开源数据库 // 打开源数据库
sourceDB, err := sql.Open("sqlite", sourceDBPath) sourceDB, err := sql.Open("sqlite", sourceDBPath)
if err != nil { if err != nil {
//return fmt.Errorf("打开源数据库失败: %v", err) return fmt.Errorf("打开源数据库失败: %v", err)
} }
defer sourceDB.Close() defer sourceDB.Close()
@ -133,7 +133,7 @@ func MigrateSQLiteTable(sourceDBPath, sourceTable, targetDBPath, targetTable str
return err return err
} }
if !exists { if !exists {
//return fmt.Errorf("源表 %s 不存在,迁移终止", sourceTable) return fmt.Errorf("源表 %s 不存在,迁移终止", sourceTable)
} }
// 构建列映射 // 构建列映射
@ -144,13 +144,13 @@ func MigrateSQLiteTable(sourceDBPath, sourceTable, targetDBPath, targetTable str
rows, err := sourceDB.Query(selectSQL) rows, err := sourceDB.Query(selectSQL)
if err != nil { if err != nil {
//return fmt.Errorf("查询源数据失败: %v", err) return fmt.Errorf("查询源数据失败: %v", err)
} }
defer rows.Close() defer rows.Close()
stmt, err := targetDB.Prepare(insertSQL) stmt, err := targetDB.Prepare(insertSQL)
if err != nil { if err != nil {
//return fmt.Errorf("准备插入语句失败: %v", err) return fmt.Errorf("准备插入语句失败: %v", err)
} }
defer stmt.Close() defer stmt.Close()
@ -166,7 +166,7 @@ func MigrateSQLiteTable(sourceDBPath, sourceTable, targetDBPath, targetTable str
} }
if err := rows.Scan(ptrs...); err != nil { if err := rows.Scan(ptrs...); err != nil {
//return fmt.Errorf("读取行数据失败: %v", err) return fmt.Errorf("读取行数据失败: %v", err)
} }
batch = append(batch, values) batch = append(batch, values)