Rails で外部キー制約を設定したいなら、foreigner を使うのが良さそう。 matthuhiggins/foreigner foreigner をインストールすると、マイグレーションで外部キー制約を設定できる。 テーブル作成時なら class CreateComments < ActiveRecord::Migration def change create_table do |t| t.reference :entry t.string :content t.timestamp t.foreign_key :entries, dependent: :delete end end end テーブル変更時なら class AddForeignKeyToComments < ActiveRecord::Migration def change change_table do |t|