开发者

How to make Rails migration conditional on current RAILS_ENV?

开发者 https://www.devze.com 2023-02-14 17:45 出处:网络
How do you make a Rails migration conditional on the current RAILS_ENV? Specifically, I want to: Check a migration into head-of-master

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

精彩评论

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