I am not sure how to do a proper migration. I am guessing I don't have to tie user_id and friend_id to anything during the migration and this will be done in the models instead. Is this alright?
class CreateFriendList < ActiveRecord::Migration def up create_table :friendship do |t| t.column "user_id", :integer, :limit=>255 t.integer "friend_id", :limit=>255 t.timestamps end end def down drop_table :friendship end end
Again, do I need to specify that user_id and friend_id are foreign keys of user during the migration or is this alright?
User has_many :friendships has_many :friends, :through => :friendships Friendship belongs_to :user belongs_to :friend, :class_name => "User"
Also, for inverse_friendship, do we do the exact same db migration and just change the name friendship to inverse_friendship?