Skip to content

Instantly share code, notes, and snippets.

@remcotolsma
Last active June 1, 2016 17:27
Show Gist options
  • Save remcotolsma/110e0ea1aa5a66d8f4f5 to your computer and use it in GitHub Desktop.
Save remcotolsma/110e0ea1aa5a66d8f4f5 to your computer and use it in GitHub Desktop.
Queries to delete InfiniteWP site history and stats of deleted sites.
DELETE FROM iwp_history WHERE siteID NOT IN ( SELECT siteID FROM iwp_sites );
DELETE FROM iwp_history_additional_data WHERE historyID NOT IN ( SELECT historyID FROM iwp_history );
DELETE FROM iwp_history_raw_details WHERE historyID NOT IN ( SELECT historyID FROM iwp_history );
DELETE FROM iwp_site_stats WHERE siteID NOT IN ( SELECT siteID FROM iwp_sites );
DELETE FROM iwp_user_access WHERE siteID NOT IN ( SELECT siteID FROM iwp_sites );
DELETE FROM iwp_groups_sites WHERE siteID NOT IN ( SELECT siteID FROM iwp_sites );
UPDATE iwp_sites SET adminUsername = 'todo' WHERE adminUsername = 'pronamic';
SELECT
s.siteID,
s.URL,
s.name,
s.adminUsername
FROM
iwp_sites AS s
LEFT JOIN
iwp_groups_sites AS gs
ON gs.siteID = s.siteID
WHERE
gs.groupID = 3
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment