feat: modify pkg

This commit is contained in:
Rogee
2024-11-28 19:30:36 +08:00
parent 900b260698
commit 554db07758
14 changed files with 100 additions and 241 deletions

View File

@@ -1,15 +1,10 @@
package db
import (
"database/sql"
"fmt"
"gorm.io/gorm"
)
func TruncateTable(db *gorm.DB, table string) {
if db.Dialector.Name() == "postgres" {
db.Exec(fmt.Sprintf("TRUNCATE TABLE %s RESTART IDENTITY", table))
return
}
db.Exec(fmt.Sprintf("TRUNCATE TABLE %s", table))
func TruncateTable(db *sql.DB, table string) {
db.Exec(fmt.Sprintf("TRUNCATE TABLE %s RESTART IDENTITY", table))
}