Add script to populate last active at

This commit is contained in:
Jorge Manrubia
2025-04-04 10:11:32 +02:00
parent 6f93d4b72a
commit a4a2ea47ba
2 changed files with 9 additions and 1 deletions
@@ -4,4 +4,3 @@ class AddLastActiveAtToBubbles < ActiveRecord::Migration[8.1]
add_index :bubbles, %i[ last_active_at status ]
end
end
+9
View File
@@ -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