1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-19 13:19:39 +02:00
Maybe/db/migrate/20240813170608_fix_invalid_accountable_data.rb

16 lines
457 B
Ruby
Raw Normal View History

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