Created
August 10, 2012 22:44
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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