Skip to content

Instantly share code, notes, and snippets.

@digitalchild
Last active August 15, 2017 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digitalchild/6c6ac086e1a08fd4e3befd7cc2b7e16f to your computer and use it in GitHub Desktop.
Save digitalchild/6c6ac086e1a08fd4e3befd7cc2b7e16f to your computer and use it in GitHub Desktop.
Clean up commission table
-- DO NOT RUN THIS ON YOUR PRODUCTION SYSTEM WITHOUT TESTING IT
-- REVERSE Commissions RUN THIS ONE ONLY. DO NOT RUN THE SECOND COMMAND
-- FIRST COMMAND HERE
UPDATE `wp_pv_commission` SET `status`='reversed' WHERE `order_id` NOT IN ( SELECT `ID` as `order_id` from `wp_posts` where `post_type` = 'shop_order' and `post_status` != 'trash' );
-- DESTRUCTIVE - USE AS LAST RESORT
-- SECOND COMMAND
-- Deletes all commission rows from the database that doesn't have a corresponding order in the database
DELETE FROM `wp_pv_commission` WHERE `order_id` NOT IN ( SELECT `ID` as `order_id` from `wp_posts` where `post_type` = 'shop_order' and post_status != 'trash' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment