class SO2DB::CreateRelationships

Public Instance Methods

up() click to toggle source
# File lib/so2db/migrations.rb, line 167
def up
  add_fk(:badges, :users)
  add_fk(:comments, :posts)
  add_fk(:comments, :users)
  add_fk(:posts, :posts, column: 'parent_id')

  # The following relationship is currently suspect, see
  # http://meta.stackoverflow.com/questions/131975/what-are-the-posttypeids-in-the-2011-12-data-dump
  add_fk(:posts, :posts, column: 'accepted_answer_id')
  
  add_fk(:posts, :users, column: 'owner_user_id')
  add_fk(:posts, :users, column: 'last_editor_user_id')
  add_fk(:post_history, :posts)
  add_fk(:post_history, :users)

  # In my experience, the following is also suspect
  add_fk(:votes, :posts)
  
  add_fk(:votes, :users)
end