Is it possible to define composite primary key for

2019-04-21 01:45发布

This question already has an answer here:

I'm using ActiveRecord in a ruby project without rails. I need to define composite primary key for a table.Normally migration creates primary key automatically. Is it possible to define my own composite primary key for a table using active record?

2条回答
Luminary・发光体
2楼-- · 2019-04-21 02:29

Question has been asked before, checkout: How to set composite key in Rails application

http://compositekeys.rubyforge.org/ might also be useful.

查看更多
闹够了就滚
3楼-- · 2019-04-21 02:45

There are some gems that give you this ability, such as composite_primary_key.

I don't know if Rails 4 has added support for this, would be very interested to hear if it does.

查看更多
登录 后发表回答