Skip to content

Commit

Permalink
Add foreign keys on relevant columns
Browse files Browse the repository at this point in the history
  • Loading branch information
emman27 committed Sep 23, 2016
1 parent c0efe6a commit dc95aee
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
11 changes: 11 additions & 0 deletions db/migrate/20160923075832_add_foreign_keys.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class AddForeignKeys < ActiveRecord::Migration
def change
ActiveRecord::Base.transaction do
add_foreign_key :gifts, :users, column: :creator_id, index: true
add_foreign_key :gifts, :users, column: :updater_id, index: true

add_foreign_key :contributions, :users, column: :creator_id, index: true
add_foreign_key :contributions, :users, column: :updater_id, index: true
end
end
end
Binary file added db/schema.mwb
Binary file not shown.
6 changes: 5 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20160912074252) do
ActiveRecord::Schema.define(version: 20160923075832) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -89,6 +89,10 @@
add_index "users", ["uid", "provider"], name: "index_users_on_uid_and_provider", unique: true, using: :btree

add_foreign_key "contributions", "gifts"
add_foreign_key "contributions", "users", column: "creator_id"
add_foreign_key "contributions", "users", column: "updater_id"
add_foreign_key "gifts", "users", column: "creator_id"
add_foreign_key "gifts", "users", column: "recipient_id"
add_foreign_key "gifts", "users", column: "updater_id"
add_foreign_key "notifications", "users"
end

0 comments on commit dc95aee

Please sign in to comment.