Difference between rake db:migrate db:reset and db:schema:load

后端 未结 5 736
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-22 11:48

The difference between rake db:migrate and rake db:reset is pretty clear in my head. The thing which I don\'t understand is how rake db:schem

5条回答
  •  时光取名叫无心
    2020-11-22 12:22

    UPDATED for Rails 5:

    db:create - Creates the database for the current RAILS_ENV environment. If RAILS_ENV is not specified it defaults to the development and test databases.

    db:create:all - Creates the database for all environments.

    db:drop - Drops the database for the current RAILS_ENV environment. If RAILS_ENV is not specified it defaults to the development and test databases.

    db:drop:all - Drops the database for all environments.

    db:migrate - Runs migrations for the current environment that have not run yet. By default it will run migrations only in the development environment.

    db:migrate:redo - Runs db:migrate:down and db:migrate:up or db:migrate:rollback and db:migrate:up depending on the specified migration.

    db:migrate:up - Runs the up for the given migration VERSION.

    db:migrate:down - Runs the down for the given migration VERSION.

    db:migrate:status - Displays the current migration status.

    db:migrate:rollback - Rolls back the last migration.

    db:version - Prints the current schema version.

    db:forward - Pushes the schema to the next version.

    db:seed - Runs the db/seeds.rb file.

    db:schema:load Recreates the database from the schema.rb file.

    db:schema:dump Dumps the current environment’s schema to db/schema.rb.

    db:structure:load - Recreates the database from the structure.sql file.

    db:structure:dump - Dumps the current environment’s schema to db/structure.sql. (You can specify another file with SCHEMA=db/my_structure.sql)

    db:setup Runs db:create, db:schema:load and db:seed.

    db:reset Runs db:drop and db:setup. db:migrate:reset - Runs db:drop, db:create and db:migrate.

    db:test:prepare - Check for pending migrations and load the test schema. (If you run rake without any arguments it will do this by default.)

    db:test:clone - Recreate the test database from the current environment’s database schema.

    db:test:clone_structure - Similar 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.

    db:environment:set - Set the current RAILS_ENV environment in the ar_internal_metadata table. (Used as part of the protected environment check.)

    db:check_protected_environments - Checks if a destructive action can be performed in the current RAILS_ENV environment. Used internally when running a destructive action such as db:drop or db:schema:load.

提交回复
热议问题