Ruby on Rails 8 cheatsheet
Ruby on Rails 8: Database
8 common Ruby on Rails 8 tasks.
Roll back the last migration
Undo the most recent migration.
bin/rails db:rollback
Caution: Rolling back can drop columns or tables and their data.
Prepare the database
Create the database if it is missing, then migrate. Safe to run repeatedly.
bin/rails db:prepare
Drop and recreate the database
Drop, recreate, load the schema and seed.
bin/rails db:reset
Caution: Deletes all data in the database for the current environment.
Open the database shell
Open psql, mysql or sqlite3, depending on your configuration.
bin/rails dbconsole