[Ruby On Rails] How to reset DB in Heroku

It is a memorandum.

background

I wanted to reset heroku's database and see if the production environment works from a clean state with nothing registered. However, because the heroku run rails db: migrate command was executed with the migration files rolled back and edited mixed, the message "We are sorry but something went wrong." Was displayed. Therefore, I decided to reset the database.

About resetting database on heroku

Correct reset method

% heroku run rails db:reset DISABLE_DATABASE_ENVIRONMENT_CHECK=1

Wrong reset method

At the beginning, I used to enter and execute commands like this. It was not reset.

% heroku run rails db:reset

rails 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

If you do not enter the environment variable DISABLE_DATABASE_ENVIRONMENT_CHECK = 1, the production database may be destroyed.

Recommended Posts

[Ruby On Rails] How to reset DB in Heroku
[Rails MySQL] How to reset DB on heroku
[Ruby on Rails] How to install Bootstrap in Rails
[Rails / Heroku / MySQL] How to reset the DB of Rails application on Heroku
[Ruby on Rails] How to write enum in Japanese
How to use Ruby on Rails
How to display a graph in Ruby on Rails (LazyHighChart)
[Ruby on Rails] How to use CarrierWave
Deploy to Heroku [Ruby on Rails] Beginner
[Ruby on Rails] How to use redirect_to
[Ruby on Rails] How to use kaminari
[Ruby on Rails] How to display error messages
How to add / remove Ruby on Rails columns
[Ruby on Rails] How to use session method
How to create a query using variables in GraphQL [Using Ruby on Rails]
How to deploy on heroku
How to implement gem "summer note" in wysiwyg editor in Ruby on Rails
How to debug the processing in the Ruby on Rails model only on the console
[Ruby on Rails] How to change the column name
(Ruby on Rails6) How to create models and tables
How to resolve errors that occur in the "Ruby on Rails" integration test
How to implement image posting function using Active Storage in Ruby on Rails
How to deploy jQuery on Rails
[rails] How to display db information
How to iterate infinitely in Ruby
[Rails] How to write in Japanese
How to deploy Bootstrap on Rails
Ruby on Rails Japanese-English support i18n
How to install Bootstrap in Ruby
Rails on Tiles (how to write)
How to introduce jQuery in Rails 6
Deploy Rails on Docker to heroku
How to install Swiper in Rails
[Ruby on Rails] Column restrictions when saving to DB (4 representatives)
Apply CSS to a specific View in Ruby on Rails
How to implement search functionality in Rails
How to change app name in rails
How to get date data in Ruby
[Rails] How to execute "rails db: create" etc. in production environment EC2
How to use custom helpers in rails
How to insert a video in Rails
How to publish an application on Heroku
Ruby on Rails in Visual Studio Codespaces
How to use MySQL in Rails tutorial
Preparing to introduce jQuery to Ruby on Rails
[rails] How to configure routing in resources
[Ruby on Rails] "|| =" ← Summary of how to use this assignment operator
How to implement ranking functionality in Rails
Beginners create portfolio in Ruby on Rails
Things to remember and concepts in the Ruby on Rails tutorial
[Ruby on Rails] Button to return to top
[Rails] How to reset the database in production environment (Capistrano version)
How to use credentials.yml.enc introduced in Rails 5.2
[Ruby on Rails] How to avoid creating unnecessary routes for devise
Change from SQLite3 to PostgreSQL in a new Ruby on Rails project
How to build a Ruby on Rails environment using Docker (for Docker beginners)
What to do when Blocked Host: "host name" appears in Ruby on Rails
How to build a Ruby on Rails development environment with Docker (Rails 6.x)
Ruby on Rails DB Tips for creating methods to reduce the load
How to solve the local environment construction of Ruby on Rails (MAC)!
How to build a Ruby on Rails development environment with Docker (Rails 5.x)