Allow to run migrations in check mode (dry run) #31630
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have found myself a lot in situations where it could be great to have ability to run migrations to report what changes they would have made rather than making them.
Of course, this can be done by running
rake db:migrate:statusto find targeted migrations, inspect their code for changes and mentally assemble those pieces in one flow. But this is tedious, slightly time consuming and error prone even for 3 migrations. And can be automated.DRY_RUNoption was added todb:migrate,db:rollback,db:migrate:upanddb:migrate:down. Fordb:migrate:upanddb:migrate:downit is not very much needed, but was added for consistency and to avoid possible surprises.The output in check mode looks like this:
If this feature will be ok for core members, I'll finish this PR by adding tests, documentation, etc.
Feedback would be greatly appreciated.