I'm getting a weird error. I had sqlite3 working and now switching over to postgres, i'm getting this error.
I have migrations, and I had to add a new column.
create_ideas migration
class CreateIdeas < ActiveRecord::Migration
def change
create_table :ideas do |t|
t.string :name
t.text :description
t.string :picture
t.timestamps
end
add_foreign_key :ideas, :lists
end
end
add_list_id_column_to_ideas migration
class AddListIdColumnToIdeas < ActiveRecord::Migration
def change
add_column :ideas, :list_id, :integer
end
end
What is wrong with my foreign key? I get the error when I do rake db:migrate
I have another migration with foreign key, and no errors yet? Maybe its catching the first error first before seeing the other one, but I have this one too:
create_comments migration
class CreateComments < ActiveRecord::Migration
def change
create_table :comments do |t|
t.string :user_name
t.text :body
t.integer :idea_id
t.timestamps
end
add_foreign_key :comments, :ideas
end
end
last migration I have create_lists
class CreateLists < ActiveRecord::Migration
def change
create_table :lists do |t|
t.string :name
t.text :description
t.string :picture
t.timestamps
end
end
end
Any clue why I'm getting errors?
Thanks
edit
my relationships
comments model
belongs_to :idea
idea model
belongs_to :list
has_many :comments
list model
has_many :ideas
CreateLists
migration has already been run before theCreateIdeas
correct? – Deekor Apr 29 at 0:33CreateIdeas
is first to run. Also, to give a sense of my relations: in my comments model I havebelongs_to :ideas
and then in my idea model I havebelongs_to :list
andhas_many :comments
and then in my list model I havehas_many :ideas
– andrewliu Apr 29 at 0:35CreateLists
be run first to create the list table before trying to make the list table a foreign key? – Deekor Apr 29 at 0:37rake db:migrate:up VERSION = 2013...
the version number of create_list file and then I triedrake db:migrate
but it still gives errors. I also tried to do the version of just the create_idea also, but still doesn't work. – andrewliu Apr 29 at 3:42