title: How do I add a new join table for two existing tables in Rails?
body: <p>My current association looks like this:</p>
  <pre><code>class Location &lt; ApplicationRecord
    has_many :instructors
  end
  
  class Instructor &lt; AppliactionRecord
    belongs_to :location
  end
  </code></pre>
  <p>I want to introduce a new <code>location_instructors</code> table that joins the above tables. Ideally, my association would turn into this:</p>
  <pre><code>class Location &lt; ApplicationRecord
    has_many :location_instructors
    has_many :instructors, through: :location_instructors
  end
  
  class LocationInstructor &lt; ApplicationRecord
    belongs_to :location
    belongs_to :instructor
  end
  
  class Instructor &lt; ApplicationRecord
    has_many :location_instructors
    has_many :locations, through: :location_instructors
  end
  
  </code></pre>
  <p>My main concern is that dropping the <code>location_id</code> column on the instructors table will make Rails not know which instructor belongs to which location anymore. How would I approach this new migration to make sure that there are <code>location_instructors</code> records for existing locations and instructors?</p>