Files
pgson/build/truncate.go
2025-11-06 00:54:41 +01:00

20 lines
384 B
Go

package build
import (
"fmt"
"git.secnex.io/secnex/pgson/schema"
"git.secnex.io/secnex/pgson/utils"
)
func TruncateSQL(s *schema.Table, cascade bool, restartIdentity bool) (string, error) {
query := fmt.Sprintf("TRUNCATE TABLE %s", utils.SQLQuoteIdent(s.Name))
if cascade {
query += " CASCADE"
}
if restartIdentity {
query += " RESTART IDENTITY"
}
return query, nil
}