Created
January 15, 2011 21:02
-
-
Save gkleiman/781251 to your computer and use it in GitHub Desktop.
This file contains 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 HasManyThroughExample < ActiveRecord::Migration | |
def self.up | |
create_table :user do |t| | |
t.string :name, :null => false | |
t.string :email | |
t.timestamps | |
end | |
create_table :projects do |t| | |
t.integer :user_id, :null => false | |
t.string :name, :null => false | |
t.timestamps | |
end | |
create_table :project_collaborators do |t| | |
t.integer :user_id, :null => false | |
t.integer :project_id, :null => false | |
t.timestamps | |
end | |
add_index :project_collaborators, [:project_id, :user_id], :unique => true | |
end | |
def self.down | |
remove_index :project_collaborators, [:project_id, :user_id], :unique => true | |
drop_table :project_collaborators | |
drop_table :projects | |
drop_table :users | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment