Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Don't know how to build task 'db:create'

I'm migrating from a sqllite db to mysql2. I have mysql running (and changed database.yml) but for some reason my rake db:create comes back with:

rake aborted!
Don't know how to build task 'db:create'

When I do a: rake -T, no db tasks appear in the list.

I'm on Rails 3.2.9

What obvious thing am I missing here?

like image 913
Arthur Frankel Avatar asked Feb 01 '13 01:02

Arthur Frankel


2 Answers

Just figured it out. Someone had commented out the following in application.rb:

require 'rails/all'

Once put back rake -T returns the db tasks.

like image 54
Arthur Frankel Avatar answered Nov 13 '22 14:11

Arthur Frankel


For people landing here in 2019:

If you ran rails new with -O (Capital 'O') or --skip-activerecord and want to add a database later, you need to uncomment this in application.rb to enable the Active Record framework:

require "active_record/railtie"

Edit:
You will also need to create the following structure in your application's root dir:

your_app
  |_config
    |_ database.yml
  |_db
    |_ migrate
    |_ schema.rb

then run:
rake db:schema:dump

like image 36
rdalpra Avatar answered Nov 13 '22 12:11

rdalpra