2016-10-05 14:49:17 +03:00
|
|
|
class TalkPreference < ActiveRecord::Base
|
|
|
|
self.primary_key = :unique_id
|
2024-09-13 19:13:40 +03:00
|
|
|
serialize :talks, type: Array, coder: JSON
|
2016-10-05 14:49:17 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
class SelectedTalk < ApplicationRecord
|
|
|
|
end
|
|
|
|
|
|
|
|
class CreateSelectedTalks < ActiveRecord::Migration[5.0]
|
|
|
|
def up
|
|
|
|
create_table :selected_talks do |t|
|
|
|
|
t.references :talk, foreign_key: false
|
|
|
|
t.string :talk_preference_id, foreign_key: true
|
|
|
|
end
|
|
|
|
|
|
|
|
talk_preferences = TalkPreference.all
|
|
|
|
|
|
|
|
talk_preferences.each do |preference|
|
|
|
|
preference.talks.each do |talk|
|
|
|
|
SelectedTalk.create! talk_id: talk, talk_preference_id: preference.unique_id
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
drop_table :selected_talks
|
|
|
|
end
|
|
|
|
end
|