Reset Rails DB Environment after a Pull

When you pull production data from Heroku to your local development environment, the data includes metadata for the environment from which it was pulled. This means that your local development database is tagged as a production database, and Rails will give it extra protection.

If you try to drop that database, you will get an error like:

ActiveRecord::ProtectedEnvironmentError: You are attempting to run a destructive action against your 'production' database.

To reset the database environment to development, and thus be allowed to drop it, you can run the following command:

bin/rails db:environment:set RAILS_ENV=development

🎩 HT: Zieski