Activerecord 如何使用外键创建迁移脚本
我想通过迁移脚本创建带有外键的表Activerecord 如何使用外键创建迁移脚本,activerecord,ruby-on-rails-2,Activerecord,Ruby On Rails 2,我想通过迁移脚本创建带有外键的表 create_table :posts do |t| t.string :title end create_table :comments do |t| t.references :post end 在rakedb:migrate之后,post没有通过id引用注释 如何在rails-2.2.3中创建此功能?您可以将迁移创建为普通表模式,并使用:primary\u key option for bellings\u to以更广泛地支持旧模式和使用单独外
create_table :posts do |t|
t.string :title
end
create_table :comments do |t|
t.references :post
end
在rakedb:migrate
之后,post没有通过id引用注释
如何在rails-2.2.3中创建此功能?您可以将迁移创建为普通表模式,并使用:primary\u key option for bellings\u to以更广泛地支持旧模式和使用单独外键的模式:
属于:posts,:foreign\u key=>“post\u id”
我想在数据库级别执行此操作。