feat: Change CreateSchemaFromJson to CreateSchema

This commit is contained in:
Björn Benouarets
2025-11-05 15:06:17 +01:00
parent e006490de2
commit 89246cae77
4 changed files with 31 additions and 14 deletions

View File

@@ -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
}