diff --git a/app/models/relationship.rb b/app/models/relationship.rb new file mode 100644 index 00000000..210bc921 --- /dev/null +++ b/app/models/relationship.rb @@ -0,0 +1,2 @@ +class Relationship < ActiveRecord::Base +end diff --git a/db/migrate/20141130130221_create_relationships.rb b/db/migrate/20141130130221_create_relationships.rb new file mode 100644 index 00000000..838d0fea --- /dev/null +++ b/db/migrate/20141130130221_create_relationships.rb @@ -0,0 +1,14 @@ +class CreateRelationships < ActiveRecord::Migration + def change + create_table :relationships do |t| + t.integer :source_id + t.integer :target_id + + t.timestamps + end + + add_index :relationships, :source_id + add_index :relationships, :target_id + add_index :relationships, [:source_id, :target_id], unique: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 3b8da33b..83c90912 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20141129211448) do +ActiveRecord::Schema.define(version: 20141130130221) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -59,6 +59,17 @@ ActiveRecord::Schema.define(version: 20141129211448) do add_index "questions", ["user_id", "created_at"], name: "index_questions_on_user_id_and_created_at", using: :btree + create_table "relationships", force: true do |t| + t.integer "source_id" + t.integer "target_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "relationships", ["source_id", "target_id"], name: "index_relationships_on_source_id_and_target_id", unique: true, using: :btree + add_index "relationships", ["source_id"], name: "index_relationships_on_source_id", using: :btree + add_index "relationships", ["target_id"], name: "index_relationships_on_target_id", using: :btree + create_table "users", force: true do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false