Llama.new
Llama.new

Reputation: 357

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!

Upvotes: 7

Views: 4778

Answers (3)

Nguyen Hong Nhat
Nguyen Hong Nhat

Reputation: 61

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

Upvotes: 4

Andrey Deineko
Andrey Deineko

Reputation: 52357

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.

Upvotes: 18

Ursus
Ursus

Reputation: 30056

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.

Upvotes: 2

Related Questions