Carson Reinke's (🚗☀☔🔑) Blog

Gem Used Only For A Migration

Figured out how to do this, mostly by the insight here.  Added a Gemfile just for the migration, included the project’s Gemfile with instance_eval(File.read(File.join(File.dirname( __FILE__ ), '..', '..', 'Gemfile'))).  When running the migration, just added in environment variable BUNDLE_GEMFILE to use that migration specific Gemfile.

bundler - rails - migration