Skip to content

Instantly share code, notes, and snippets.

@DavidAntaramian
Created August 10, 2012 22:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavidAntaramian/3318703 to your computer and use it in GitHub Desktop.
Save DavidAntaramian/3318703 to your computer and use it in GitHub Desktop.
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