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

cmd/atlas/internal/cmdapi: new "schema diff" flag to error out on diff. #3281

Closed
wants to merge 1 commit into from

Conversation

pylaligand
Copy link

This makes it easier to programmatically verify that migrations are up-to-date with e.g. an ORM-generated schema in a CI context by observing the command's return code rather than parsing its output.

This makes it easier to programmatically verify that migrations are
up-to-date with e.g. an ORM-generated schema in a CI context by
observing the command's return code rather than parsing its output.
@pylaligand
Copy link
Author

Happy new year! Anyone to review this? @a8m maybe?

@a8m
Copy link
Member

a8m commented Jan 6, 2025

Thanks for the contribution, @pylaligand. Currently, in order to implement something like this in CI, you can do it this way:

atlas schema diff \
  --from "file://migrations" \
  --to env://orm \
  --env local \
  --format '{{ if .Changes }}The failure message{{ end }}' | grep '.' && exit 1

Or, convert it to if [ -n "$output" ]; then .. fi.

This is flexible enough because users can control the error message and the format of the failure. If we'll add such flag, we also need to support a way to customize its message, which I prefer to avoid.

@pylaligand
Copy link
Author

Makes sense, thanks.

@pylaligand pylaligand closed this Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants