koa
koa

Reputation: 515

Any heroku/rails approach to prevent accident db data destruction?

I am at a point where I have multiple production heroku apps and several more in development.

For the apps in active development, i often run commands like heroku run rake db:setup, rake db:seed to reset data while I am still doing early development.

There is a risk that I could accidentally run these commands while in a heroku command prompt for a production app which would be bad.

In short, is it possible to disable certain rake tasks(db:reset, db:setup, db:seed) for heroku apps rails.

Upvotes: 0

Views: 200

Answers (1)

Ben Walding
Ben Walding

Reputation: 4054

Add a task dependency to the appropriate 'dangerous' tasks:

task :env_check_development => :environment do
    raise Exception.new("CAN ONLY RUN IN DEVELOPMENT") unless ::Rails.env.development?
end

task 'db:migrate' => :env_check_development

Then:

$ RAILS_ENV=test rake db:migrate

rake aborted!
CAN ONLY RUN IN DEVELOPMENT

Upvotes: 3

Related Questions