Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
cat <<EOF | foreman-rake console
conf.return_format = ""
batch_size = 1000
persistence =
adapter = persistence.adapter
plans_without_tasks = adapter.db.fetch("select dynflow_execution_plans.uuid from dynflow_execution_plans left join foreman_tasks_tasks on (dynflow_execution_plans.uuid = foreman_tasks_tasks.external_id) where IS NULL")
deleted = 0
total = plans_without_tasks.count{|x| x[:uuid]}.in_groups_of(batch_size, false).each do |uuids|
delete_count = persistence.delete_execution_plans({ 'uuid' => uuids }, batch_size)
deleted += delete_count
puts "deleted #{deleted} out of #{total}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment