Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Migration to create a has_and_belongs_to_many join table between the Club model and the People model
class ClubsPeople < ActiveRecord::Migration
def change
create_table :clubs_people, :id => false do |t|
t.references :person, :club
end
add_index :clubs_people, [:club_id, :person_id], :unique => true, :name => "by_club_person"
end
end
class CorrectJoinTableNames < ActiveRecord::Migration
def up
rename_table(:people_clubs, :clubs_people)
end
def down
rename_table(:clubs_people, :people_clubs)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment