diff --git a/db/migrate/20250404072651_add_last_active_at_to_bubbles.rb b/db/migrate/20250404072651_add_last_active_at_to_bubbles.rb index 56db5d162..c1e9e4723 100644 --- a/db/migrate/20250404072651_add_last_active_at_to_bubbles.rb +++ b/db/migrate/20250404072651_add_last_active_at_to_bubbles.rb @@ -4,4 +4,3 @@ class AddLastActiveAtToBubbles < ActiveRecord::Migration[8.1] add_index :bubbles, %i[ last_active_at status ] end end - diff --git a/script/fill_last_active_at.rb b/script/fill_last_active_at.rb new file mode 100755 index 000000000..cfad6315a --- /dev/null +++ b/script/fill_last_active_at.rb @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby + +require_relative "../config/environment" + +ApplicationRecord.with_each_tenant do |tenant| + Bubble.find_each do |bubble| + bubble.update! last_active_at: bubble.events.last&.created_at || Time.current + end +end