开发者

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:

  1. Check a migration into head-of-master
  2. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜