Created
October 31, 2011 13:37
-
-
Save scottkf/1327498 to your computer and use it in GitHub Desktop.
Self-referential rails example
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 CreatePeople < ActiveRecord::Migration | |
def change | |
create_table :people do |t| | |
t.string :name | |
t.timestamps | |
end | |
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 CreatePersonRelationships < ActiveRecord::Migration | |
def change | |
create_table :person_relationships do |t| | |
t.integer :parent_id | |
t.integer :child_id | |
t.timestamps | |
end | |
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
ActiveRecord::Schema.define(:version => 20100401133415) do | |
create_table "people", :force => true do |t| | |
t.string "name" | |
t.datetime "created_at" | |
t.datetime "updated_at" | |
end | |
create_table "person_relationships", :force => true do |t| | |
t.integer "parent_id" | |
t.integer "child_id" | |
t.datetime "created_at" | |
t.datetime "updated_at" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment