blob: 1c43a4d1a7c0376f6c846df957a67dd56c3a3251 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
class AddPtypeToParticipants < ActiveRecord::Migration[4.2]
def self.up
add_column :participants, :ptype, :string
assign_participant_type
end
def self.down
remove_column :participants, :ptype
end
private
def self.assign_participant_type
Participant.all.each do |p|
case
when p.mainparticipant? then p.ptype= Participant::TYPE[:main]
when p.subparticipant? then p.ptype= Participant::TYPE[:sub]
when p.anonymousparticipant? then p.ptype= Participant::TYPE[:anonym]
end
p.save!
end
end
end
|