简体   繁体   中英

Rake or Rails db:migrate

I am new to RoR and am starting on the guide at http://guides.rubyonrails.org/getting_started.html .

When I run the command bin/rails db:migrate , I get the error command db:migrate not recognized

But I am able to run the command bin/rake db:migrate without any issues.

My question is : is there any difference between the two or can I just rest easy and use rake? Thanks!

It depends on version of Rails. Before Rails 5.0 it was

rake db:migrate

Starting from Rails 5.0 it is

rails db:migrate

From changelog:

One Rails Command instead of the split-brain setup between rake and rails, so now it's bin/rails db:migrate instead of bin/rake db:migrate

See changelog for full list of changes in Rails 5.

Which version of rails gem are you using? In rails 5 (the guide you linked is for rails 5) we use rails command for everything. Before rails 5 we used rake for db commands.

Rails is framework.

Rake is a standalone Ruby utility that replaces the Unix utility 'make', and uses a 'Rakefile' and .rake files to build up a list of tasks. In Rails, Rake is used for common administration tasks, especially sophisticated ones that build off of each other.”

You can view more : https://www.tutorialspoint.com/ruby-on-rails/rails-and-rake.htm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM