如何在 Rails Active Record 中关闭 auto_increment [英] How to turn off auto_increment in Rails Active Record
本文介绍了如何在 Rails Active Record 中关闭 auto_increment的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在 ActiveRecord 中创建没有 auto_increment
标志的主键?
Is it possible to create primary key without auto_increment
flag in ActiveRecord?
我做不到
create table :blah, :id => false
因为我想在列上有主键索引.我查找了文档,但没有找到任何有用的信息.
because I want to have primary key index on the column. I looked up documentation but didn't find anything useful.
是否可以在没有 auto_increment 的情况下创建主键?
推荐答案
试试这个?
create_table(:table_name, :id => false) do |t|
t.integer :id, :options => 'PRIMARY KEY'
end
这篇关于如何在 Rails Active Record 中关闭 auto_increment的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文