Rake db:migrate ';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::::::::::::::::::::::::::::::::::::::::::; https://melvinchng.github.io/rails/CreateARailsApplication.html#27-more-rake-db-command

 


2.7 More rake db Command

This table is compiled by Jaco Pretorites. He combined the information shown in Table 2.7.1 from StackOverflow and Rails source code. In his website, he explains all different Rails db Rake Tasks and what each task they do. Personally, I have not tried all the commands and do not guarantee it will work. In order for the commands below to work, you have to add rake to each of the command. For example, for the first command in the table, we have to use rake db:create.

Table 2.7.1: All Rails db Rake Tasks and What They Do

CommandDescription
db:createCreates the database for the current RAILS_ENV environment. If RAILS_ENV is not specified it defaults to the development and test databases.
db:create:allCreates the database for all environments.
db:dropDrops the database for the current RAILS_ENV environment. If RAILS_ENV is not specified it defaults to the development and test databases.
db:drop:allDrops the database for all environments.
db:migrateRuns migrations for the current environment that have not run yet. By default it will run migrations only in the development environment.
db:migrate:redoRuns db:migrate:down and db:migrate:up or db:migrate:rollback and db:migrate:migrate depending on the specified migration. I usually run this after creating and running a new migration to ensure the migration is reversible.
db:migrate:upRuns the up for the given migration VERSION.
db:migrate:downRuns the down for the given migration VERSION.
db:migrate:statusDisplays the current migration status.
db:migrate:rollbackRolls back the last migration.
db:versionPrints the current schema version.
db:forwardPushes the schema to the next version.
db:seedRuns the db/seeds.rb file.
db:schema:loadLoads the schema into the current environment’s database.
db:schema:dumpDumps the current environment’s schema to db/schema.rb.
db:setupRuns db:schema:load and db:seed.
db:resetdb:drop and db:setup.
db:migrate:resetRuns db:drop, db:create and db:migrate.
db:test:prepareCheck for pending migrations and load the test schema. (If you run rake without any arguments it will do this by default.)
db:test:cloneRecreate the test database from the current environment’s database schema.
db:test:clone_structureSimilar to db:test:clone, but it will ensure that your test database has the same structure, including charsets and collations, as your current environment’s database.

Comments

Popular posts from this blog

Rails 7 Features :: Comparison with Rails 6 and Rails 5