diff --git a/README.md b/README.md index 8669e1c..f34eb28 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,7 @@ sub commands: version: show version generate: command "generate" description diff: command "diff" description + apply: command "apply" description options: --trace (env: DDLCTL_TRACE, default: false) diff --git a/go.mod b/go.mod index 0d05b03..c04341c 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,6 @@ module github.com/kunitsucom/ddlctl go 1.21.5 require ( - github.com/kunitsucom/util.go v0.0.60-rc.3 + github.com/kunitsucom/util.go v0.0.60-rc.4 github.com/lib/pq v1.10.9 ) diff --git a/go.sum b/go.sum index 832ab47..c2ed327 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,4 @@ -github.com/kunitsucom/util.go v0.0.60-rc.3 h1:BUP+IyIzdjEq2t2V7hYt4+8dd6nO7d4oZM9Pa1e5hGY= -github.com/kunitsucom/util.go v0.0.60-rc.3/go.mod h1:bYFf2JvRqVF1brBtpdt3xkkTGJBxmYBxZlItrc/lf7Y= +github.com/kunitsucom/util.go v0.0.60-rc.4 h1:TGqi1YeOgfh4dScSfI6C14HDhoX2qCkbWEak5ZIV1Q4= +github.com/kunitsucom/util.go v0.0.60-rc.4/go.mod h1:bYFf2JvRqVF1brBtpdt3xkkTGJBxmYBxZlItrc/lf7Y= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= diff --git a/pkg/ddlctl/ddlctl_apply.go b/pkg/ddlctl/ddlctl_apply.go index 76d828a..cc16d15 100644 --- a/pkg/ddlctl/ddlctl_apply.go +++ b/pkg/ddlctl/ddlctl_apply.go @@ -25,7 +25,10 @@ func Apply(ctx context.Context, args []string) error { return errorz.Errorf("args=%v: %w", args, apperr.ErrTwoArgumentsRequired) } - left, right, err := resolve(ctx, config.Dialect(), args[0], args[1]) + dsn := args[0] + ddlSrc := args[1] + + left, right, err := resolve(ctx, config.Dialect(), dsn, ddlSrc) if err != nil { return errorz.Errorf("resolve: %w", err) } @@ -36,7 +39,6 @@ func Apply(ctx context.Context, args []string) error { } msg := ` - ddlctl will exec the following DDL queries: -- 8< -- @@ -45,7 +47,7 @@ ddlctl will exec the following DDL queries: -- >8 -- -Do you want to apply these DDL? +Do you want to apply these DDL queries? ddlctl will exec the DDL queries described above. Only 'yes' will be accepted to approve. @@ -67,7 +69,7 @@ Enter a value: ` os.Stdout.WriteString("\nexecuting...\n") - db, err := sqlz.OpenContext(ctx, _postgres, args[0]) + db, err := sqlz.OpenContext(ctx, _postgres, dsn) if err != nil { return errorz.Errorf("sqlz.OpenContext: %w", err) } @@ -88,7 +90,7 @@ func prompt() error { userInput := scanner.Text() switch userInput { - case "yes", "YES": + case "yes": return nil default: return errorz.Errorf("userInput=%s: %w", userInput, apperr.ErrUserCanceled)