如何关闭AUTO_INCREMENT Rails中的Active RecordRails、AUTO_INCREMENT、Record、Active

由网友(孤傲的背影)分享简介:是否有可能创建没有 AUTO_INCREMENT 标志中的主键的ActiveRecord Is it possible to create primary key without auto_increment flag in ActiveRecord?我不能这样做。create table :blah, :id...

是否有可能创建没有 AUTO_INCREMENT 标志中的主键的ActiveRecord

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
阅读全文

相关推荐

最新文章