Files
fizzy/db/migrate/20250117142146_associate_events_with_bubbles.rb
T
Kevin McConnell e6fe7f680d Associate Event with Bubble
It's kind of a long way to get from one to the other right now. Every
event belongs to a bubble, so let's link them directly.
2025-01-17 14:40:36 +00:00

18 lines
459 B
Ruby

class AssociateEventsWithBubbles < ActiveRecord::Migration[8.1]
def change
change_table :events do |t|
t.references :bubble, foreign_key: true
end
execute "
update events
set bubble_id = m.bubble_id
from event_summaries es
join messages m on m.messageable_type = 'EventSummary' and m.messageable_id = es.id
where events.summary_id = es.id
"
change_column_null :events, :bubble_id, false
end
end