ActiveRecord Migration Notes hooks into the Rails migrations and monitors if the migrations contain a note methods that should be shown afterwards.
Have you ever been in a situation where you have to deploy some code and forgot what special things you had to execute manually after a migration?
Searching for this answer within pull requests, issues, code comments, tickets, emails, faxes made me think this should be easier.
Why not give the developer who creates the migration, an easy way to add some additional notes to the migration?
Add this line to your Rails application's Gemfile:
gem 'activerecord-migration_notes'
And then execute:
$ bundle
You can now add two new methods within your migration called up_notes
(trigged on rake db:migrate
) and down_notes
(triggered on rake db:rollback
).
Both these methods are optional and you do not have to specify them both.
class AddSomeBreakingChanges < ActiveRecord::Migration
def change
# your normal migration task
end
def up_notes
<<-NOTES
Please run the following manually to not break the DB!
$ rake some_task
NOTES
end
def down_notes
"All is well no additional notes"
end
end
- test if we covered all other cases like
db:down
anddb:up
- ... more?
- probably add some docs
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
The gem is available as open source under the terms of the MIT License.