【发布时间】:2011-08-18 07:44:24
【问题描述】:
我想在 Rails 3 下创建一个bigint(或string 或任何不是int)类型的主键字段。
我有一个给定的数据结构,例如:
things
------
id bigint primary_key
name char(32)
我目前正在尝试推动的方法:
create_table :things, :id => false do |t| # That prevents the creation of (id int) PK
t.integer :id, :limit => 8 # That makes the column type bigint
t.string :name, :limit => 32
t.primary_key :id # This is perfectly ignored :-(
end
列类型将是正确的,但主键选项不会出现在 sqlite3 中,我怀疑 MySQL 也是这种情况。
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 primary-key bigint