class CreateWorkDetailManuals < ActiveRecord::Migration def change create_table :work_detail_manuals do |t| t.date :evaluation_start t.date :evaluation_end t.integer :evaluation_num t.references :work t.timestamps end add_index :work_detail_manuals, :work_id Work.all.each do |work| WorkDetailManual.create(:work_id => work.id, :evaluation_start => work.end_time + 7, :evaluation_end => work.end_time + 14, :evaluation_num => 3) end end end