class AddLocationToCharacter < ActiveRecord::Migration[6.1] def change add_reference :characters, :location, foreign_key: true Character.all.each do |character| character.update(location_id: Location.find_by_gid("floret").id) end change_column :characters, :location_id, :bigint, null: false end end