mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 20:14:08 +00:00
Fix for invalid accountable data (#1086)
This commit is contained in:
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
|
||||
Reference in New Issue
Block a user