0

I've created table

create_table :friendships , :force => true, :id => false do |t|
  t.integer :person_id
  t.integer :friend_id
end  

Now i need to create id for that table. how can i do that in migration?

Elmor
  • 4,775
  • 6
  • 38
  • 70
  • minute after i've asked i found an answer http://stackoverflow.com/questions/5328528/how-do-i-retroactively-add-a-primary-key-to-my-table-in-rails – Elmor Nov 20 '12 at 09:57
  • so please post your answer as an answer of your question and accept it. – Thanh Nov 20 '12 at 10:35

1 Answers1

0

The command to add a primary key in a migration is:

add_column :my_table, :id, :primary_key
Elmor
  • 4,775
  • 6
  • 38
  • 70