2015-08-14 23:40:32 +03:00
|
|
|
class Event < ActiveRecord::Base
|
|
|
|
has_one :proposition, as: :proposable
|
|
|
|
end
|
|
|
|
|
|
|
|
class Proposition < ActiveRecord::Base
|
|
|
|
belongs_to :proposable, polymorphic: true
|
|
|
|
end
|
|
|
|
|
2019-04-28 11:56:16 +03:00
|
|
|
class AddTrackIdToEvents < ActiveRecord::Migration[4.2]
|
2015-08-14 23:40:32 +03:00
|
|
|
def up
|
|
|
|
add_reference :events, :track, index: true, foreign_key: true
|
|
|
|
|
|
|
|
Event.all.includes(:proposition).each do |event|
|
|
|
|
event.update!(track_id: event.proposition.proposition_accepting_id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
remove_reference :events, :track, index: true, foreign_key: true
|
|
|
|
end
|
|
|
|
end
|