Files
atom/utils/db/db.go
2023-07-06 19:05:29 +08:00

16 lines
268 B
Go

package db
import (
"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))
}