diff options
author | Richard Schneeman <richard.schneeman@gmail.com> | 2016-01-11 13:57:53 -0600 |
---|---|---|
committer | Richard Schneeman <richard.schneeman@gmail.com> | 2016-01-11 13:57:53 -0600 |
commit | 83215b86fe46d2974c472436dc3337581d17829c (patch) | |
tree | 82324ac01ad68ac2891e6e56a9783db37a3a36d4 /activerecord/lib/active_record/migration.rb | |
parent | 179df9df68396a6916f62192971838b7e73d5f76 (diff) | |
parent | eafa43e870cb595b8efd95323082c9fd3e50caab (diff) | |
download | rails-83215b86fe46d2974c472436dc3337581d17829c.tar.gz rails-83215b86fe46d2974c472436dc3337581d17829c.tar.bz2 rails-83215b86fe46d2974c472436dc3337581d17829c.zip |
Merge pull request #23015 from schneems/schneems/manual-environment-set
Allow manually setting environment value
Diffstat (limited to 'activerecord/lib/active_record/migration.rb')
-rw-r--r-- | activerecord/lib/active_record/migration.rb | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index f699e83ab3..4a6e9c12fe 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -145,7 +145,7 @@ module ActiveRecord class NoEnvironmentInSchemaError < MigrationError #:nodoc: def initialize - msg = "Environment data not found in the schema. To resolve this issue, run: \n\n\tbin/rake db:migrate" + msg = "Environment data not found in the schema. To resolve this issue, run: \n\n\tbin/rake db:environment:set" if defined?(Rails.env) super("#{msg} RAILS_ENV=#{::Rails.env}") else @@ -157,7 +157,7 @@ module ActiveRecord class ProtectedEnvironmentError < ActiveRecordError #:nodoc: def initialize(env = "production") msg = "You are attempting to run a destructive action against your '#{env}' database\n" - msg << "if you are sure you want to continue, run the same command with the environment variable\n" + msg << "If you are sure you want to continue, run the same command with the environment variable\n" msg << "DISABLE_DATABASE_ENVIRONMENT_CHECK=1" super(msg) end @@ -165,10 +165,15 @@ module ActiveRecord class EnvironmentMismatchError < ActiveRecordError def initialize(current: nil, stored: nil) - msg = "You are attempting to modify a database that was last run in #{ stored } environment.\n" - msg << "You are running in #{ current } environment." - msg << "if you are sure you want to continue, run the same command with the environment variable\n" - msg << "DISABLE_DATABASE_ENVIRONMENT_CHECK=1" + msg = "You are attempting to modify a database that was last run in `#{ stored }` environment.\n" + msg << "You are running in `#{ current }` environment." + msg << "If you are sure you want to continue, first set the environment using:\n\n" + msg << "\tbin/rake db:environment:set" + if defined?(Rails.env) + super("#{msg} RAILS_ENV=#{::Rails.env}") + else + super(msg) + end end end |