Reputation: 23
class CreateComments < ActiveRecord::Migration
def change
create_table :comments do |t|
t.integer :link_id
t.text :body
t.references :user, index: true, foreign_key: true
t.timestamps null: false
end
add_index :comments, :link_id
end
end
I was deploying my app to heroku and had to redo the database in Pg insteand of sqlite 3. When I migrate my database I am gettting this
NameError: uninitialized constant CreateCommments
I have been search SO all day and tried many of the solutions but to no avail. I have searched spelling errors, dropped, recreated the database. My database.yml is up to date and gem and gemlock are clean of sqlite, but it will not stop yelling at me. Thank you in advance.
Upvotes: 0
Views: 733
Reputation: 14890
The error is because the filename is incorrect. It has to be a timestamp with the class name then in snake case, like
20170602175844_create_comments.rb
You can of course do this manually and just change the filename, or run in the console and get a new migration
rails g migration create_comments
Note:
It doesn't have to be a timestamp though, that's just the way the rails rake task does it. You can also use a numerical sequence like if you create your files manually. This is just done to be able to see what migrations have already run and to be able to rollback to a specific version. Also so that the migrations run in a specific order.
1_create_comments.rb
Upvotes: 2