Fix for invalid accountable data (#1086)

This commit is contained in:
Zach Gollwitzer
2024-08-15 12:49:49 -04:00
committed by GitHub
parent 1f6f55c4a8
commit acf3564a86
3 changed files with 18 additions and 26 deletions

View File

@@ -0,0 +1,15 @@
class FixInvalidAccountableData < ActiveRecord::Migration[7.2]
def up
Account.all.each do |account|
unless account.accountable
puts "Generating new accountable for id=#{account.id}, name=#{account.name}, type=#{account.accountable_type}"
new_accountable = Accountable.from_type(account.accountable_type).new
account.update!(accountable: new_accountable)
end
end
end
def down
# Not reversible
end
end