aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/railties
diff options
context:
space:
mode:
authorschneems <richard.schneeman@gmail.com>2016-01-11 10:22:26 -0600
committerschneems <richard.schneeman@gmail.com>2016-01-11 11:00:34 -0600
commiteafa43e870cb595b8efd95323082c9fd3e50caab (patch)
tree82324ac01ad68ac2891e6e56a9783db37a3a36d4 /activerecord/lib/active_record/railties
parent179df9df68396a6916f62192971838b7e73d5f76 (diff)
downloadrails-eafa43e870cb595b8efd95323082c9fd3e50caab.tar.gz
rails-eafa43e870cb595b8efd95323082c9fd3e50caab.tar.bz2
rails-eafa43e870cb595b8efd95323082c9fd3e50caab.zip
Allow manually setting environment value
If for some reason some one is not able to set the environment from a migration this gives us an escape valve to manually set the environment for the database see https://github.com/rails/rails/pull/22967#issuecomment-170251635. We will also fix the migration case, but this will ensure there is always a way to set the environment. cc/ @sgrif
Diffstat (limited to 'activerecord/lib/active_record/railties')
-rw-r--r--activerecord/lib/active_record/railties/databases.rake6
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake
index ead9407391..d81d6b54b3 100644
--- a/activerecord/lib/active_record/railties/databases.rake
+++ b/activerecord/lib/active_record/railties/databases.rake
@@ -1,6 +1,12 @@
require 'active_record'
db_namespace = namespace :db do
+ desc "Set the environment value for the database"
+ task "environment:set" => [:environment, :load_config] do
+ ActiveRecord::InternalMetadata.create_table
+ ActiveRecord::InternalMetadata[:environment] = ActiveRecord::Migrator.current_environment
+ end
+
task :check_protected_environments => [:environment, :load_config] do
ActiveRecord::Tasks::DatabaseTasks.check_protected_environments!
end