-
Notifications
You must be signed in to change notification settings - Fork 913
feat(verify): Add new command to verify queries and migrations #2986
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
Conversation
func annotate() map[string]string { | ||
labels := map[string]string{} | ||
for _, ev := range envvars { | ||
key := strings.ReplaceAll(strings.ToLower(ev), "_", ".") | ||
labels[key] = os.Getenv(ev) | ||
} | ||
outs, err := readOutputs(up.dir, result) | ||
return labels | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's frowned upon these days but this seems like a case for init()
internal/cmd/push.go
Outdated
var pushCmd = &cobra.Command{ | ||
Use: "push", | ||
Aliases: []string{"upload"}, | ||
Short: "Push the schema, queries, and configuration to your project", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This used to be "...for this project" which is maybe not ideal but I think is clearer than "...to your project"
internal/cmd/push.go
Outdated
} | ||
p := &pusher{} | ||
if err := Process(ctx, p, dir, filename, opts); err != nil { | ||
os.Exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should just be return err
no?
internal/cmd/verify.go
Outdated
|
||
var verifyCmd = &cobra.Command{ | ||
Use: "verify", | ||
Short: "Verify schema, queries, and configuration against main", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think "against main" means anything here. I don't have a better idea at the moment, but I think just saying "Verify schema, queries, and configuration for this project"
would be fine for now.
internal/cmd/verify.go
Outdated
// hmmm | ||
os.Exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason we can't just return err here?
Only generate one output pair per queryset for upload / verify
push
We've renamed the upload sub-command to push. Using
upload
is supported for now, but please switch over to usingpush
. We changed the data sent along in a push request. Upload used to include the configuration file, migrations, queries, and all generated code. Push drops the generated code in favor of including the [plugin.GenerateRequest], which is the protobuf message we pass to codegen plugins.We now pass along annotations for each push. By default, we include these environment variables if they are present:
Like upload, push should be run when you tag a release of your application. We run it on every push to main, as we continuously deploy those commits.
verify
The verify command, building on top of the push command, ensures migrations are safe to deploy. Verify sends your current schema and queries to sqlc cloud. There, we run the queries for your latest push against your new schema changes. This check catches backwards incompatible schema changes for existing queries.