Moved deletion of secondary tables before the deletion of machine table to satisfy the constraints, otherwise the deletion of records in MySQL and PostgreSQL would fail, as the constraints weren't satisfied. This caused the database not to be pruned when using MySQL and PostgreSQL, and the machine number to grow with every restart