16 lines
268 B
Go
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))
|
|
}
|