是否有可能使用活动记录为表定义复合主键? [英] Is it possible to define composite primary key for table using active record?
本文介绍了是否有可能使用活动记录为表定义复合主键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在没有导轨的ruby项目中使用ActiveRecord。我需要为表定义复合主键。正常情况下,迁移会自动创建主键。是否有可能使用活动记录为表定义我自己的复合主键?
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?
推荐答案
有一些宝石可以提供这种功能,例如 composite_primary_key 。
There are some gems that give you this ability, such as composite_primary_key.
我不知道Rails 4是否增加了对此的支持,如果确实如此,它会非常感兴趣。
I don't know if Rails 4 has added support for this, would be very interested to hear if it does.
这篇关于是否有可能使用活动记录为表定义复合主键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文