Reputation: 429
I'm following this tutorial,
and I'm having a problem when running rake db:migrate
In db/migrate
I have the create_post.rb
file:
class CreatePosts < ActiveRecord::Migration
def change
create_table :posts do |t|
t.string :title
t.text :text
t.timestamps
end
end
end
But it does not create the table.
My database.yml
file is:
development:
adapter: mysql2
encoding: utf8
database: blog_development
pool: 5
username: root
password:
socket: /tmp/mysql.sock
The output from rake db:migrate
seems ok.
I'm using phpMyAdmin
to handle the database, which is correctly created manually by me.
What am I doing wrong?
Upvotes: 1
Views: 8338
Reputation: 349
If nothing stated above works please do check your schema.rb for migration contents. If migration contents are already there then just do the below command in production:
rails db:schema:load RAILS_ENV=production.
Upvotes: 1
Reputation: 1239
If you are connecting to the right database everything seems fine to me.. I had a similar problem a few weeks ago and the accepted answer of this question fixed my issue.
Here are the steps to run:
rake db:drop:all
rake db:create:all
rake db:migrate
I hope it will fix your problem.
WARNING: this will erase your database.
Upvotes: 2
Reputation: 47
Could you please tell which OS you got? Delete the line:
socket: /tmp/mysql.sock
and run:
db:migrate
Give the output of:
db:migrate:status
If this is not working for you, you could also try to add:
host: 127.0.0.1
to your database.yml file
Upvotes: 1