mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-21 14:19:39 +02:00
15 lines
457 B
Ruby
15 lines
457 B
Ruby
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
|