Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(keys): Correcting the primary key changes #12

Merged
merged 4 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/schema/cmd_generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ func (g *generateCmd) Usage() string {

func (g *generateCmd) SetFlags(f *flag.FlagSet) {
f.StringVar(&g.templatesLocation, "templates", "./templates/*.tmpl", "The location of the templates to use.")
f.StringVar(&g.outputLocation, "output", ".", "The location to write the generated files to.")
f.StringVar(&g.sqlLocation, "sql", "./*.sql", "The location of the SQL files to use.")
f.StringVar(&g.outputLocation, "out", ".", "The location to write the generated files to.")
f.StringVar(&g.sqlLocation, "sql", "./pkg/models/*.sql", "The location of the SQL files to use.")
}

func (g *generateCmd) Execute(_ context.Context, _ *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
Expand Down
6 changes: 6 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ go 1.22

require (
github.com/Masterminds/sprig v2.22.0+incompatible
github.com/go-sql-driver/mysql v1.8.0
github.com/google/subcommands v1.2.0
github.com/huandu/xstrings v1.4.0
github.com/pingcap/tidb v2.0.7+incompatible
github.com/stretchr/testify v1.4.0
)

require (
filippo.io/edwards25519 v1.1.0 // indirect
github.com/BurntSushi/toml v0.0.0-20170626110600-a368813c5e64 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver v1.4.2 // indirect
Expand All @@ -19,6 +22,7 @@ require (
github.com/coreos/etcd v3.2.18+incompatible // indirect
github.com/cznic/mathutil v0.0.0-20180504122225-ca4c9f2c1369 // indirect
github.com/cznic/sortutil v0.0.0-20150617083342-4c7342852e65 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c // indirect
Expand All @@ -44,6 +48,7 @@ require (
github.com/pingcap/pd v2.0.5+incompatible // indirect
github.com/pingcap/tipb v0.0.0-20180621072330-658ea9c14169 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.11.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.26.0 // indirect
Expand All @@ -63,6 +68,7 @@ require (
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0-20170531160350-a96e63847dc3 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
)

replace github.com/pingcap/tidb v2.0.7+incompatible => github.com/darkliquid/tidb v2.0.6-0.20180920112946-471a025d5769+incompatible
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/BurntSushi/toml v0.0.0-20170626110600-a368813c5e64 h1:BuYewlQyh/jroxY8qx41SrzD8Go17GkyCyAeVmprvQI=
github.com/BurntSushi/toml v0.0.0-20170626110600-a368813c5e64/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
Expand Down Expand Up @@ -39,6 +41,8 @@ github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vb
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-sql-driver/mysql v1.8.0 h1:UtktXaU2Nb64z/pLiGIxY4431SJ4/dR5cjMmlVHgnT4=
github.com/go-sql-driver/mysql v1.8.0/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
Expand Down
1 change: 1 addition & 0 deletions pkg/models/column.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func (c *Column) setOptions(col *ast.ColumnDef) error {
case ast.ColumnOptionPrimaryKey:
c.InPrimaryKey = true
c.InUniqueKey = true
c.Nullable = false // Primary keys are not nullable
case ast.ColumnOptionUniqKey:
c.InUniqueKey = true
default:
Expand Down
5 changes: 1 addition & 4 deletions pkg/models/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,8 @@ func (t *Table) setTableOptions(ct *ast.CreateTableStmt) error {
switch opt.Tp {
case ast.TableOptionComment:
t.Comment = opt.StrValue
case ast.TableOptionEngine,
ast.TableOptionCharset:
// ignore
default:
slog.Warn("unknown table option", slog.Int("type", int(opt.Tp)))
// ignore
}
}

Expand Down
Loading
Loading