18 lines
353 B
Go
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
|
|
}
|