سؤال

Is there a way to only run migrations in the test environment?

I'd like to create tables and seed the data in only the test environment since the staging and production databases already exist.

هل كانت مفيدة؟

المحلول

I've found a solution based on the post here. This allows me to only apply the migration against the test environment.

class CreateLicenseDatabase < ActiveRecord::Migration
  def change
    if Rails.env.test?

      create_table.....

    end
  end
end

نصائح أخرى

Can't you just do this:

RAILS_ENV=test rake db:create
RAILS_ENV=test rake db:migrate

?

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top