Reputation: 5859
I have the following migrations
Problem is that rake db:migrate
is not executing the first migration and no users
table is created.
What could be the reason for this?
Upvotes: 1
Views: 1539
Reputation: 76774
What could be the reason for this?
Main reason is probably that you've already ran the migration - or perhaps later migrations - and Rails therefore does not think it needs to run it.
A good way to see if this is the case is to open your db/schema.rb
file:
You'll see the latest migration your schema is running. If this supersedes the one you're trying to invoke, it will not run.
--
Fixes
You could generate a new migration, and copy the code over:
$ rails g migration AddUsers2
You'd then add the following:
#db/migrate/_____.rb
class AddUsers2 < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name
t.timestamps
end
end
end
Alternatively, you could wipe your DB and start again. This can be achieved using rake schema:load
. THIS WILL WIPE ALL DATA AND START AGAIN
Upvotes: 2