我创建ID为bigint的表
class Hoge < ActiveRecord::Migration
def change
create_table :hoges, id: false do |t|
t.column :id, :serial8, primary_key: true
t.integer :bar, null: false
end
end
end
并在模型上设置primary_key
class Hoge < ActiveRecord::Base
self.primary_key = :id
end
然后,我exec迁移,开发数据库创建成功
Column | Type | Modifiers
--------------+-----------------------------+----------------------------------------------------------
id | integer | not null default nextval('hoges_id_seq'::regclass)
bar | integer | not null
然后,我执行"耙子测试"测试数据库已创建,但它无效。默认值为 0.....
Column | Type | Modifiers
--------------+-----------------------------+----------------------------------------------------------
id | integer | not null default 0
bar | integer | not null
为什么测试环境的数据库不是同一个开发环境?(数据库是邮政)
应使用命令 rake db:test:prepare