How to make Rails migration conditional to current RAILS_ENV?

How do you fulfill the Rails migration condition in the current RAILS_ENV?

In particular, I want:

  • Check transition to the main server
  • Only migrate to our Stage instance

This will allow us to perform database updates โ€” through the migrations that we only want in our intermediate environment. An example would be the activation of a function for a specific account or class of accounts for testing purposes.

+6
ruby-on-rails rails-migrations
source share
1 answer

Just use Rails.env.production? / Rails.env.<custom-env>? in their up / down class methods in Migration.

+12
source share

All Articles