fix(repo): 改进初始化和种子命令的错误处理
- 在初始化命令失败时记录具体错误信息- 在种子命令失败时记录具体错误信息 - 添加 SQLite 驱动导入以支持数据库操作
This commit is contained in:
@@ -2,12 +2,12 @@ package repo
|
||||
|
||||
func (repo *SqlRepository) Init() {
|
||||
if _, err := repo.Commands.Init.ExecContext(repo.Context); err != nil {
|
||||
repo.Logger.Panic("Cannot exec init command")
|
||||
repo.Logger.Panicf("Cannot exec init command: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (repo *SqlRepository) Seed() {
|
||||
if _, err := repo.Commands.Seed.ExecContext(repo.Context); err != nil {
|
||||
repo.Logger.Panic("Cannot exec seed command")
|
||||
repo.Logger.Panicf("Cannot exec seed command: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package repo
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
_ "modernc.org/sqlite"
|
||||
"os"
|
||||
"platform/config"
|
||||
"platform/logging"
|
||||
|
||||
Reference in New Issue
Block a user