feat: Change CreateSchemaFromJson to CreateSchema
This commit is contained in:
@@ -3,7 +3,6 @@ package schema
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Table struct {
|
||||
@@ -96,15 +95,3 @@ func (f *Field) SQLReferences() string {
|
||||
}
|
||||
return fmt.Sprintf(" REFERENCES %s(%s)", f.References.Table, f.References.Column)
|
||||
}
|
||||
|
||||
func (t *Table) CreateSQL() (string, error) {
|
||||
if err := t.Validate(); err != nil {
|
||||
return "", err
|
||||
}
|
||||
schemaParts := make([]string, len(t.Schema))
|
||||
for i, field := range t.Schema {
|
||||
schemaParts[i] = field.SQL()
|
||||
}
|
||||
query := fmt.Sprintf("CREATE TABLE %s (%s)", t.Name, strings.Join(schemaParts, ",\n"))
|
||||
return query, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user