List all tasks
You can find all the database tasks Rails provides by running the following command from a Rails application directory.
➜ blog (main) ✗ bin/rails help | grep db:
db:create
db:drop
...
Summary
db:create: Creates the database unless it already exists.
db:drop: Drops the database if it exists.
db:environment:set: Fixes the EnvironmentMismatchError or NoEnvironmentInSchemaError, raised if the environment data is not found in the schema, by setting the current environment in the internal table.
db:fixtures:load: It loads the fixtures, i.e., the sample data that you want to test against. They are stored in the YAML file under the test/fixtures/ directory.
db:migrate: Runs all the migrations that have not run yet, for the current environment.
db:migrate:down: Reverts the transformations performed by the last migration's up method by running the down method.
db:migrate:redo: Rolls back the database one migration and re-migrates up.
db:migrate:status: Displays the status of migrations.
db:migrate:up: Runs the up method for a given migration.
db:prepare: Runs setup if the database does not exist. Otherwise, it runs the migrations.
db:reset: Resets your database using your migrations for the current environment. It does this by running the db:drop, db:create, db:migrate tasks.
db:rollback: Rolls the schema back to the previous version, undoing the migration that you just ran. If you want to undo previous n migrations, pass STEP=n to this task.
db:schema:cache:clear: Clears the db/schema_cache.yml file generated by the db:schema:cache:dump task.
db:schema:cache:dump: Creates a db/schema_cache.yml file.
db:schema:dump: Creates a database schema file (either db/schema.rb or db/structure.sql, depending on config.active_record.schema_format).
db:schema:load: Loads a database schema file (either db/schema.rb or db/structure.sql, depending on config.active_record.schema_format) into the database.
db:seed: Loads the seed data from db/seeds.rb file.
db:seed:replant: Truncates tables of each database for the current environment and loads the seeds
db:setup: Creates all databases db:create, loads all schemas db:schema:load, and initializes with the seed data db:seed. However, it won't drop the database first if it exists. Use db:reset to also drop all databases first.
db:structure:dump: Deprecated. It was used to dump the structure.sql file.
db:structure:load: Deprecated. It was used to load the structure.sql file.
For some history behind why these tasks were deprecated, check out this wtf. No, seriously.
db:system:change: Running rails new generator without specifying a database sets your app with sqlite. It's a hassle to change the database later. This task helps you easily change the database by delegating to the rails db:change SYSTEM=postgresql|mysql|whatever generator.
db:version: Prints the current schema version number.
Source: All the Database Tasks in Rails