Add conference_id to Event
This commit is contained in:
parent
00a4e32939
commit
52901e976c
|
@ -2,7 +2,7 @@ class Event < ActiveRecord::Base
|
||||||
include Proposable
|
include Proposable
|
||||||
|
|
||||||
has_one :track, through: :proposition, source: :proposition_accepting, source_type: Track
|
has_one :track, through: :proposition, source: :proposition_accepting, source_type: Track
|
||||||
has_one :conference, through: :track
|
belongs_to :conference
|
||||||
|
|
||||||
has_many :participations
|
has_many :participations
|
||||||
has_many :pending_participations, ->() { pending }, class_name: 'Participation'
|
has_many :pending_participations, ->() { pending }, class_name: 'Participation'
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
class Event < ActiveRecord::Base
|
||||||
|
has_one :proposition, as: :proposable
|
||||||
|
end
|
||||||
|
|
||||||
|
class Proposition < ActiveRecord::Base
|
||||||
|
belongs_to :proposable, polymorphic: true
|
||||||
|
belongs_to :proposition_accepting, polymorphic: true
|
||||||
|
end
|
||||||
|
|
||||||
|
class Track < ActiveRecord::Base
|
||||||
|
end
|
||||||
|
|
||||||
|
class AddConferenceIdToEvents < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
add_reference :events, :conference, index: true, foreign_key: true
|
||||||
|
|
||||||
|
Event.all.includes(:proposition).each do |event|
|
||||||
|
event.update!(conference_id: event.proposition.proposition_accepting.conference_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
remove_reference :events, :conference, index: true, foreign_key: true
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue