I have the following table that is migrated already in my Database.
class CreateHouses < ActiveRecord::Migration[7.0]
def change
create_table :houses do |t|
t.bigint :owner_id, null: false
end
end
end
I want to create a new migration to update the owner_id field and link it to owners table.
I've previously tried a few, but they all failed. I tried the following but did not worked as well.
class AddOwnerIdRefToOwners < ActiveRecord::Migration[7.0]
def change
add_reference :owners, :owner_id, null: false, foreign_key: true
end
end