How to make Rails migration conditional on current RAILS_ENV?
How do you make a Rails migration conditional on the current RAILS_ENV?
Specifically, I want to:
- Check a migration into head-of-master
- Execute the migration only on our Staging instance
Doing this will allow us to pe开发者_如何学Pythonrform database updates - via migrations - which we only want in our Staging environment. An example would be activating a feature for a specific account or class of accounts for testing purposes.
Just use Rails.env.production?
/ Rails.env.<custom-env>?
in your up / down class methods in the Migration.
精彩评论