Last active
August 15, 2017 09:49
-
-
Save digitalchild/6c6ac086e1a08fd4e3befd7cc2b7e16f to your computer and use it in GitHub Desktop.
Clean up commission table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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