由网友(眼底尽藏温柔)分享简介:我如何可以改变(默认)类型的ActiveRecord的标识? int是不够长,长我会preFER。我很惊讶,有没有?长的迁移 - 做一件只需要使用一些十进制How can I change the (default) type for ActiveRecord's IDs? int is not long enoug...
我如何可以改变(默认)类型的ActiveRecord的标识? int是不够长,长我会preFER。我很惊讶,有没有?长的迁移 - 做一件只需要使用一些十进制
How can I change the (default) type for ActiveRecord's IDs? int is not long enough, I would prefer long. I was surprised that there is no :long for the migrations - does one just use some decimal?
推荐答案
贷http://moeffju.net/blog/using-bigint-columns-in-rails-migrations
class CreateDemo < ActiveRecord::Migration
def self.up
create_table :demo, :id => false do |t|
t.integer :id, :limit => 8
end
end
end
查看选项:ID =&GT;假
它禁用自动创建id字段的
的 t.integer:ID,:上限=&GT; 8
线将产生64位整型字段
See the option :id => false
which disables the automatic creation of the id field
The t.integer :id, :limit => 8
line will produce a 64 bit integer field
相关推荐
最新文章