mirror of
https://github.com/we-promise/sure.git
synced 2026-04-07 22:34:47 +00:00
16 lines
457 B
Ruby
16 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
|