fix(data): remove orphaned targeted_user_links
This commit is contained in:
parent
54a47fadae
commit
ba1035bd30
1 changed files with 18 additions and 0 deletions
|
@ -0,0 +1,18 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: clean_orphaned_targeted_user_links'
|
||||
task clean_orphaned_targeted_user_links: :environment do
|
||||
puts "Running deploy task 'clean_orphaned_targeted_user_links'"
|
||||
|
||||
progress = ProgressReport.new(TargetedUserLink.count)
|
||||
TargetedUserLink.find_each do |tul|
|
||||
if tul.target_model.nil?
|
||||
tul.destroy
|
||||
end
|
||||
progress.inc
|
||||
end
|
||||
# Update task as completed. If you remove the line below, the task will
|
||||
# run with every deploy (or every time you call after_party:run).
|
||||
AfterParty::TaskRecord
|
||||
.create version: AfterParty::TaskRecorder.new(__FILE__).timestamp
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue