aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeiko Bernloehr <Heiko.Bernloehr@FreeIT.de>2015-04-21 10:26:25 +0200
committerHeiko Bernloehr <Heiko.Bernloehr@FreeIT.de>2016-01-27 01:50:45 +0100
commitdafe3f1723501ebba3f10847eb37f360b4693e67 (patch)
treec90ce967a653df9ae338abbee181dc1ca1439768
parentc4c0d3425190df6ad1e0617dcccc4d5f5f4bf17e (diff)
downloadecs2-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.rb23
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