Skip to content

Commit a1a91e2

Browse files
committed
Only ask people to run migration in a environment in non-development environments
When running test, you might have pending migrations. Before Rails would tell you to run migrations with RAILS_ENV=test. This causes the problem that now the development environment still have pending migrations. The correct workflow is to run migrations in the development environment and let Rails prepare the test database based on the schema or structure file. In the development environment we don't need to tell to use the `RAILS_ENV` environment variable.
1 parent f297e6a commit a1a91e2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

activerecord/lib/active_record/migration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def initialize(message = nil)
150150
private
151151
def detailed_migration_message
152152
message = "Migrations are pending. To resolve this issue, run:\n\n bin/rails db:migrate"
153-
message += " RAILS_ENV=#{::Rails.env}" if defined?(Rails.env)
153+
message += " RAILS_ENV=#{::Rails.env}" if defined?(Rails.env) && !(Rails.env.development? || Rails.env.test?)
154154
message += "\n\n"
155155

156156
pending_migrations = ActiveRecord::Base.connection.migration_context.open.pending_migrations

0 commit comments

Comments
 (0)