According to http://meta.serverfault.com/a/1931 , I will answer this as an answer, although some of the information is in the comment thread.
The connection table created by Rails does not have a primary key (i.e. created by create_join_table , which is used to migrate with JoinTable in their name), and Rails does not have an inherent requirement for one. This is because for most pure join tables only the join table identifier is used, in which case primary_key is not required. You can, of course, add and label the primary key column if you wish.
Rails does not support multiple primary_keys columns, although there are several gems that support this support, such as https://github.com/composite-primary-keys/composite_primary_keys .
In addition, there is no fundamental need to create an index. You can create it, if you want, and speed up access to records due to the additional time spent on creating and updating a record. See fooobar.com/questions/52275 / ... for more details.
source share