How to drop a production database in Rails 5
Public
20 Aug 10:36

I encountered a problem when dropping a production database.

RAILS_ENV=production bundle exec rake db:drop

# this results in
# rake aborted!
# ActiveRecord::ProtectedEnvironmentError: You are attempting to run a destructive action against your 'production' database.
# If you are sure you want to continue, run the same command with the environment variable:
# DISABLE_DATABASE_ENVIRONMENT_CHECK=1

Here’s the solution

RAILS_ENV=production bundle exec rake db:drop DISABLE_DATABASE_ENVIRONMENT_CHECK=1

Comments

Empty! You must sign in to add comments.