mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-04 21:15:19 +02:00
Fix for invalid accountable data (#1086)
This commit is contained in:
parent
1f6f55c4a8
commit
acf3564a86
3 changed files with 18 additions and 26 deletions
15
db/migrate/20240813170608_fix_invalid_accountable_data.rb
Normal file
15
db/migrate/20240813170608_fix_invalid_accountable_data.rb
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue