Task to check missing foreing ids in spree_line_items

This commit is contained in:
cyrillefr
2024-05-29 10:32:21 +02:00
parent c81e7f3b5d
commit 65fc144a46

View File

@@ -0,0 +1,28 @@
# frozen_string_literal: true
namespace :ofn do
namespace :data do
desc 'Checking missing required ids in Spree::LineItem'
task check_missing_required_missing_ids_in_spree_line_items: :environment do
puts 'Checking for null order_id'
ids = Spree::LineItem.where(order_id: nil).pluck(:id)
if ids.empty?
puts 'No NULL order_id found in spree_line_items'
else
puts 'NULL order_ids s have been found in spree_line_items:'
print ids
end
puts 'Checking for null variant_id'
ids = Spree::LineItem.where(variant_id: nil).pluck(:id)
if ids.empty?
puts 'No NULL variant_id found in spree_line_items'
else
puts 'NULL variant_id s have been found in spree_line_items:'
print ids
end
end
end
end