Files
pgson/build/create.go
2025-11-05 15:06:17 +01:00

18 lines
353 B
Go

package build
import (
"fmt"
"strings"
"git.secnex.io/secnex/pgson/schema"
)
func Create(s *schema.Table) (string, error) {
schemaParts := make([]string, len(s.Schema))
for i, field := range s.Schema {
schemaParts[i] = field.SQL()
}
query := fmt.Sprintf("CREATE TABLE %s (%s)", s.Name, strings.Join(schemaParts, ",\n"))
return query, nil
}