Skip to content

Commit

Permalink
Disabled Rake tasks in production
Browse files Browse the repository at this point in the history
  • Loading branch information
just3ws committed Jan 28, 2015
1 parent 0828f8b commit 87b6fd9
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/tasks/disable_db_tasks_on_production.rake
@@ -0,0 +1,28 @@
DISABLED_TASKS = [
'db:drop',
'db:migrate:reset',
'db:schema:load',
'db:seed'
# ...
]

namespace :db do
desc 'Disable a task in production environment'
task :guard_for_production do
if Rails.env.production?
if ENV['DANGER_ZONE'] != '1'
puts 'This task is disabled in production.'
puts 'If you really want to run it, call it again with `DANGER_ZONE=1`'
exit
# else
# require 'heroku'
# puts 'Making a backup of the database, just in case...'
# puts `heroku pgbackups:capture`
end
end
end
end

DISABLED_TASKS.each do |task|
Rake::Task[task].enhance(['db:guard_for_production'])
end

0 comments on commit 87b6fd9

Please sign in to comment.