Reputation: 23
Working with:
Whenever I run "rake db:migrate" no tables are created in the database.
I have created a database and named it "simple_cms_development" and changed the development part of "database.yml" accordingly:
development:
adapter: sqlite3
database: simple_cms_development
pool: 5
username: simple_cms
password: ruby
timeout: 5000
I generated and model named "User" and edited "create_users.rb" to:
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string "first_name", :limit => 25
t.string "last_name", :limit => 50
t.string "email", :default => "", :null => false
t.string "password", :limit => 40
t.timestamps
end
end
end
I run "rake db:migrate" and there is no change to the tables within the database. When I run SHOW TABLES;
in MySQL I get back "Empty set (0.00sec)". I don't even get "schema_migrations" table.
Any ideas what is going on?
Thanks!
Upvotes: 1
Views: 731
Reputation: 7820
Your database.yml
is set up to use sqlite3, not mySQL. Yours is now this:
development:
adapter: sqlite3
database: simple_cms_development
pool: 5
username: simple_cms
password: ruby
timeout: 5000
You should probably be using the mySQL2 gem, and your database.yml
should look something like this:
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: simple_cms_development
pool: 5
username: root
password: your-password
socket: /var/run/mysqld/mysqld.sock
According to this StackOverflow discussion you can get your socket by running
mysqladmin variables | grep socket
or if you have a password on your root:
mysqladmin password-here variables | grep socket`
If you want to use host and port instead of socket try this:
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: simple_cms_development
pool: 5
username: root
password: your-password
host: 127.0.0.1
port: 3306
Here is a blog with instructions on how to set up mySQL with Rails 3.2, it might help with your Rails 4 issue: http://cicolink.blogspot.com/2011/06/how-to-install-ruby-on-rails-3-with.html
Upvotes: 3