19 lines
419 B
Go
19 lines
419 B
Go
package build
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"git.secnex.io/secnex/pgson/schema"
|
|
"git.secnex.io/secnex/pgson/utils"
|
|
)
|
|
|
|
func DropSQL(s *schema.Table) (string, error) {
|
|
if s == nil {
|
|
return "", fmt.Errorf("nil table provided")
|
|
}
|
|
if s.Name == "" || !utils.IsValidIdentifier(s.Name) {
|
|
return "", fmt.Errorf("invalid table name: %q", s.Name)
|
|
}
|
|
return fmt.Sprintf("DROP TABLE IF EXISTS %s", utils.SQLQuoteIdent(s.Name)), nil
|
|
}
|