Class: SO2DB::CreateRelationships

Inherits:
Object
  • Object
show all
Includes:
FKHelper
Defined in:
lib/so2db/migrations.rb

Instance Method Summary collapse

Methods included from FKHelper

#add_fk

Instance Method Details

#upObject



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# 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