rake command executes migration.
This command should be executed application root.
rake:migrate compares schema_migrations table and db/migrate folder,
it can find migration files which are not executed.
We can rollback any steps(status) we can.
rake db commands list
|db:migrate||Migrate to the designated VERSION(if missing VERSION, go latest)|
|db:rollback||Rollback steps you decide|
|db:migrate:up||Execute up method of you decide migration file|
|db:migrate:down||Execute down method of you decide migration file|
|db:migrate:redo||Rollback several steps and redo|
|db:migrate:reset||Delete database and redo|
rake db:migrate VERSION=20140215175710 # version rake db:rollback STEP=5 # 5 steps rake db:migrate:up VERSION=20140215175710 # execute 20140215175710xxx migration file rake db:migrate:down VERSION=20140215175710 rake db:migrate:redo STEP=5 # rollback 5steps and redo rake db:migrate:reset # delete database
Basically, rake commands are applied to default database defined by database.yml
Default is development
If you want to do other database, set others
rake db:migrate RAILS_ENV=test
VERBOSE is to display process of migration
You can off this.
rake db:migrate VERBOSE=false
Recreate database using schema file
Rails keeps schema history(different from migration), db/schema.rb.
This is like all-migration files together.
Load schema file
Delete current database and load schema