clarion/db/migrate/20150729135818_create_participation_records.rb

22 lines
676 B
Ruby
Raw Normal View History

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|
2015-08-05 15:05:31 +03:00
profile = PersonalProfile.find_by(id: event_to_speaker_profile['speaker_profile_id'])
next if not profile
Participation.create! event_id: event_to_speaker_profile['event_id'],
2015-08-05 15:05:31 +03:00
participant_id: profile.user_id,
approved: true
end
end
def down
Participation.destroy_all
end
end