class AddColumnToZipPacks < ActiveRecord::Migration[5.2] def change add_column :zip_packs, :container_id, :integer, default: 0 add_column :zip_packs, :container_type, :string add_index :zip_packs, [:container_id, :container_type] ZipPack.all.update_all("container_type='HomeworkCommon', container_id = homework_id") end end