Class: SO2DB::CreateOptionals

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/so2db/migrations.rb

Instance Method Summary collapse

Instance Method Details

#create_close_reasonsObject



265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# File 'lib/so2db/migrations.rb', line 265

def create_close_reasons
  create_table :close_reasons do |t|
    #t.primary_key :id
    t.string :name, :limit => 50
  end

  { 1 => "Exact duplicate",
    2 => "off-topic",
    3 => "subjective",
    4 => "not a real question",
    7 => "too localized",
    10 => "General reference",
    20 => "Noise or pointless"
  }.each do |k,v|
    c = Models::CloseReason.new
    c.id = k
    c.name = v
    c.save
  end
end

#create_post_history_typesObject



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/so2db/migrations.rb', line 221

def create_post_history_types
  create_table :post_history_types do |t|
    #t.primary_key :id
    t.string :name, :limit => 50
  end

  { 1  => "Initial Title", 
    2  => "Initial Body", 
    3  => "Initial Tags", 
    4  => "Edit Title", 
    5  => "Edit Body", 
    6  => "Edit Tags", 
    7  => "Rollback Title", 
    8  => "Rollback Body", 
    9  => "Rollback Tags", 
    10 => "Post Closed", 
    11 => "Post Reopened", 
    12 => "Post Deleted", 
    13 => "Post Undeleted", 
    14 => "Post Locked", 
    15 => "Post Unlocked", 
    16 => "Community Owned", 
    17 => "Post Migrated", 
    18 => "Question Merged", 
    19 => "Question Protected", 
    20 => "Question Unprotected", 
    22 => "Question Unmerged", 
    24 => "Suggested Edit Applied", 
    25 => "Post Tweeted", 
    31 => "Discussion moved to chat", 
    33 => "Post Notice Added", 
    34 => "Post Notice Removed", 
    35 => "Post Migrated Away", 
    36 => "Post Migrated Here", 
    37 => "Post Merge Source", 
    38 => "Post Merge Destination" 
  }.each do |k,v|
    p = Models::PostHistoryType.new
    p.id = k
    p.name = v
    p.save
  end
end

#create_post_typesObject



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/so2db/migrations.rb', line 199

def create_post_types
  create_table :post_types do |t|
    #t.primary_key :id
    t.string :type_name, :limit => 24
  end

  { 1 => "Question", 
    2 => "Answer",
    3 => "Wiki",
    4 => "TagWikiExcerpt",
    5 => "TagWiki",
    6 => "ModeratorNomination",
    7 => "WikiPlaceholder",
    8 => "PrivilegeWiki"
  }.each do |k,v|
    p = Models::PostType.new
    p.id = k
    p.type_name = v
    p.save
  end
end

#create_vote_typesObject



286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# File 'lib/so2db/migrations.rb', line 286

def create_vote_types
  create_table :vote_types do |t|
    #t.primary_key :id
    t.string :name, :limit => 50
  end

  { 1 => "AcceptedByOriginator",
    2 =>"UpMod",
    3 => "DownMod",
    4 =>"Offensive",
    5 =>"Favorite",
    6 =>"Close",
    7 =>"Reopen",
    8 =>"BountyStart",
    9 =>"BountyClose",
    10 =>"Deletion",
    11 =>"Undeletion",
    12 =>"Spam",
    15 =>"ModeratorReview",
    16 =>"ApproveEditSuggestion"
  }.each do |k,v|
    vt = Models::VoteType.new
    vt.id = k
    vt.name = v
    vt.save
  end
end

#upObject



192
193
194
195
196
197
# File 'lib/so2db/migrations.rb', line 192

def up
  create_post_types
  create_post_history_types
  create_close_reasons
  create_vote_types
end