Skip to content

Instantly share code, notes, and snippets.

@mccun934
Last active May 31, 2018 20:27
Show Gist options
  • Save mccun934/0b4f2b0b2754730d94507b87e47eb33c to your computer and use it in GitHub Desktop.
Save mccun934/0b4f2b0b2754730d94507b87e47eb33c to your computer and use it in GitHub Desktop.
#!/bin/bash
katello-service stop
systemctl start postgresql
echo ""
echo "DELETING All task data"
echo ""
TABLE_COUNTS="select count(*) as foreman_tasks_tasks from foreman_tasks_tasks;
select count(*) as dynflow_execution_plans from dynflow_execution_plans;
select count(*) as dynflow_actions from dynflow_actions;
select count(*) as dynflow_steps from dynflow_steps;"
echo ""
echo "Table counts before:"
echo $TABLE_COUNTS | sudo -i -u postgres psql -d foreman
echo "Deleting foreman_tasks_tasks"
FT="TRUNCATE TABLE dynflow_steps,dynflow_actions,dynflow_execution_plans,foreman_tasks_locks,foreman_tasks_tasks;"
sudo -i -u postgres psql -d foreman -c "$FT"
echo "Done."
echo "Table counts after:"
echo $TABLE_COUNTS | sudo -i -u postgres psql -d foreman
katello-service start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment