Disabling Rails' db:reset task

ruby-on-rails

Solution

In your Rake file you can add

Rake.application.instance_variable_get('@tasks').delete('db:reset')

and the command is not available any more. If you want to disable multiple commands, put it in a `remove_task` method for readability.

But a better alternative seem to just not type the `rake db:reset` command, which is not something you'd accidentally type.

Having a nice backup of your (production) database is also a better solution I suppose.

Problem

To avoid an accidental 'rake db:reset' on our production environments, I was thinking about disabling 'rake db:reset' and related tasks that drop the database in the production environment. Is there an easy way to do this, or do I have to redefine the rake task? Is there a better alternative?

Original source

Related problems