Locally, you may see the error
ActiveRecord::ProtectedEnvironmentError if you attempt to access an environment that is protected, such as
production or
staging, from a context where it is prohibited.
A simple example - I made a backup of the postgresql database on Heroku. I imported it locally. And when I wanted to delete the database - I received an error about trying to delete a protected database (production).
rake db:drop;
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
DISABLE_DATABASE_ENVIRONMENT_CHECK=1
So the command to delete the protected database will look like this:
DISABLE_DATABASE_ENVIRONMENT_CHECK=1 rake db:drop;
Be careful. You need to understand what you are doing and why. Do not accidentally drop the production database of your project. The error ActiveRecord::ProtectedEnvironmentError is a safeguard against mistakenly deleting an important database.