diff options
author | Heiko Bernloehr <Heiko.Bernloehr@FreeIT.de> | 2015-04-21 10:26:25 +0200 |
---|---|---|
committer | Heiko Bernloehr <Heiko.Bernloehr@FreeIT.de> | 2016-01-27 01:50:45 +0100 |
commit | dafe3f1723501ebba3f10847eb37f360b4693e67 (patch) | |
tree | c90ce967a653df9ae338abbee181dc1ca1439768 | |
parent | c4c0d3425190df6ad1e0617dcccc4d5f5f4bf17e (diff) | |
download | ecs2-dafe3f1723501ebba3f10847eb37f360b4693e67.tar.gz ecs2-dafe3f1723501ebba3f10847eb37f360b4693e67.zip |
Fix forgotten db migration.
Forgot to commit the db migration.
-rw-r--r-- | db/migrate/20150420210728_add_ptype_to_participants.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/db/migrate/20150420210728_add_ptype_to_participants.rb b/db/migrate/20150420210728_add_ptype_to_participants.rb new file mode 100644 index 0000000..679321a --- /dev/null +++ b/db/migrate/20150420210728_add_ptype_to_participants.rb @@ -0,0 +1,23 @@ +class AddPtypeToParticipants < ActiveRecord::Migration + 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 |