feat: 删除不再使用的模板文件和相关代码,优化项目结构
This commit is contained in:
@@ -5,22 +5,11 @@ import (
|
||||
"database/sql"
|
||||
"embed"
|
||||
"fmt"
|
||||
|
||||
"github.com/go-jet/jet/v2/qrm"
|
||||
)
|
||||
|
||||
//go:embed migrations/*
|
||||
var MigrationFS embed.FS
|
||||
|
||||
type CtxDB struct{}
|
||||
|
||||
func FromContext(ctx context.Context, db *sql.DB) qrm.DB {
|
||||
if tx, ok := ctx.Value(CtxDB{}).(*sql.Tx); ok {
|
||||
return tx
|
||||
}
|
||||
return db
|
||||
}
|
||||
|
||||
func Truncate(ctx context.Context, db *sql.DB, tableName ...string) error {
|
||||
for _, name := range tableName {
|
||||
sql := fmt.Sprintf("TRUNCATE TABLE %s RESTART IDENTITY", name)
|
||||
|
||||
Reference in New Issue
Block a user