Rails best way to change relation from model to another

Viewed 32

I have this schema.

enter image description here

And I would like to change the relationship as follows.

enter image description here

I am not sure what is the best way to do it without breaking anything.

Reverting or rollback the create_varieties_wines migration ?

class CreateVarietiesWines < ActiveRecord::Migration[6.1]
  def change
    create_table :varieties_wines do |t|
      t.references :wine, null: false, foreign_key: true
      t.references :variety, null: false, foreign_key: true
      t.timestamps
    end
  end
end
0 Answers
Related