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: handle isexist error for IsDirectDeal column in migration #1761

Merged
merged 2 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion extern/boostd-data/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require (
github.com/stretchr/testify v1.8.3
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
github.com/urfave/cli/v2 v2.24.4
github.com/yugabyte/gocql v0.0.0-20221110041640-6fc475c5aeb0
github.com/yugabyte/gocql v0.0.0-20230831121436-1e2272bb6bb6
github.com/yugabyte/pgx/v4 v4.14.5
go.opentelemetry.io/otel v1.16.0
go.opentelemetry.io/otel/exporters/jaeger v1.13.0
Expand Down
4 changes: 2 additions & 2 deletions extern/boostd-data/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2113,8 +2113,8 @@ github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
github.com/ybbus/jsonrpc/v2 v2.1.6/go.mod h1:rIuG1+ORoiqocf9xs/v+ecaAVeo3zcZHQgInyKFMeg0=
github.com/yugabyte/gocql v0.0.0-20221110041640-6fc475c5aeb0 h1:68nrJsrWe0A6JiKnsjWChAaWhj20v+AwYJObtp86D1k=
github.com/yugabyte/gocql v0.0.0-20221110041640-6fc475c5aeb0/go.mod h1:LAokR6+vevDCrTxk52U7p6ki+4qELu4XU7JUGYa2O2M=
github.com/yugabyte/gocql v0.0.0-20230831121436-1e2272bb6bb6 h1:3sggdexlJg07v9sRBKkZ+/oSJ0sq53vVApx8iSbD98M=
github.com/yugabyte/gocql v0.0.0-20230831121436-1e2272bb6bb6/go.mod h1:LAokR6+vevDCrTxk52U7p6ki+4qELu4XU7JUGYa2O2M=
github.com/yugabyte/pgx/v4 v4.14.5 h1:XLzEEiO3d/kWzpyctO8l4kwMLhzPQ9n2er7ATH7CJVA=
github.com/yugabyte/pgx/v4 v4.14.5/go.mod h1:nFSvjsVq4CuA61TWGriwWG74ZVxeuJCcNu42Mkn+rgw=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cassmigrate
import (
"context"
"fmt"
"strings"

"github.com/yugabyte/gocql"
"golang.org/x/sync/errgroup"
Expand All @@ -14,7 +15,12 @@ func ts20230913144459_dealsAddIsDirectDealColumn(ctx context.Context, session *g
err := session.Query(qry).WithContext(ctx).Exec()

if err != nil {
return fmt.Errorf("creating new column IsDirectDeal: %w", err)
errorStr := strings.Split(err.Error(), ";")
if strings.Compare("code=2200", errorStr[0]) == 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd relax this directly to strings.Contains

Suggested change
errorStr := strings.Split(err.Error(), ";")
if strings.Compare("code=2200", errorStr[0]) == 0 {
if strings.Contains(err.Error(), "code=2200") {

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

log.Warn("column IsDirectDeal already exists")
} else {
return fmt.Errorf("creating new column IsDirectDeal: %w", err)
}
}

qry = `SELECT DealUuid from PieceDeal`
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ require (
github.com/quic-go/quic-go v0.38.1 // indirect
github.com/quic-go/webtransport-go v0.5.3 // indirect
github.com/ucarion/urlpath v0.0.0-20200424170820-7ccc79b76bbb // indirect
github.com/yugabyte/gocql v0.0.0-20221110041640-6fc475c5aeb0 // indirect
github.com/yugabyte/gocql v0.0.0-20230831121436-1e2272bb6bb6 // indirect
github.com/yugabyte/pgx/v4 v4.14.5 // indirect
github.com/zyedidia/generic v1.2.1 // indirect
go.opentelemetry.io/otel/metric v1.16.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1879,8 +1879,8 @@ github.com/xorcare/golden v0.6.1-0.20191112154924-b87f686d7542 h1:oWgZJmC1DorFZD
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
github.com/yugabyte/gocql v0.0.0-20221110041640-6fc475c5aeb0 h1:68nrJsrWe0A6JiKnsjWChAaWhj20v+AwYJObtp86D1k=
github.com/yugabyte/gocql v0.0.0-20221110041640-6fc475c5aeb0/go.mod h1:LAokR6+vevDCrTxk52U7p6ki+4qELu4XU7JUGYa2O2M=
github.com/yugabyte/gocql v0.0.0-20230831121436-1e2272bb6bb6 h1:3sggdexlJg07v9sRBKkZ+/oSJ0sq53vVApx8iSbD98M=
github.com/yugabyte/gocql v0.0.0-20230831121436-1e2272bb6bb6/go.mod h1:LAokR6+vevDCrTxk52U7p6ki+4qELu4XU7JUGYa2O2M=
github.com/yugabyte/pgx/v4 v4.14.5 h1:XLzEEiO3d/kWzpyctO8l4kwMLhzPQ9n2er7ATH7CJVA=
github.com/yugabyte/pgx/v4 v4.14.5/go.mod h1:nFSvjsVq4CuA61TWGriwWG74ZVxeuJCcNu42Mkn+rgw=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down