📚 Blog Archive

Disable dangerous rake tasks in production

· Miguel Parramón · blogger

Tags: rake, ruby, Ruby on Rails

Yesterday, we had to restore the production DB from a backup, since we ran “rake db:schema:load” in production by mistake. To avoid that problem in the future, I decided to disable that task, and others than can screw with the DB, in production. 

It was a matter of adding a prerequisite to those dangerous tasks, that checks if they are being run in production, and exit accordingly. I also added a flag to override this safeguard, together with some code to backup the DB. To do this, I added the following code to lib/tasks/disable_db_tasks_on_production.rake:
Read more »

View original post →