clarion/db/migrate/20150729135818_create_participation_records.rb
Petko Bordjukov 9ca34c5a22 Introduce a Participation model
This model is responsible for the 1..n - 1..n relationship between an
event and the people that will participate in it.
2015-07-31 14:40:04 +03:00

19 lines
618 B
Ruby

class Participation < ActiveRecord::Base; end
class PersonalProfile < ActiveRecord::Base; end
class CreateParticipationRecords < ActiveRecord::Migration
def up
event_to_speaker_profiles = execute 'SELECT * FROM events_speaker_profiles'
event_to_speaker_profiles.each do |event_to_speaker_profile|
Participation.create! event_id: event_to_speaker_profile['event_id'],
participant_id: PersonalProfile.find(event_to_speaker_profile['speaker_profile_id']).user_id,
approved: true
end
end
def down
Participation.destroy_all
end
end