added relationship model

This commit is contained in:
nilsding 2014-11-30 14:06:05 +01:00
parent b5b977ab5c
commit 57c4578533
3 changed files with 28 additions and 1 deletions

View File

@ -0,0 +1,2 @@
class Relationship < ActiveRecord::Base
end

View File

@ -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

View File

@ -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