Migrating Cousin Rob’s www.DRUMSTHEWORD.com website from his 6 year old Drupal6 website to a new (hopefully sexier) WordPress4 website has meant a lot of data cleansing before golive. Before we get any comments about Drupal vs. WordPress, or a CMS flamewar, the new website was chosen to be on WordPress because of WOOCOMMERCE and a neat WordPress Theme that had already been selected.
So, I’m going to leave a little blog about any particular problems I found, or cool tricks I found, during data migration.
The old drupal website had over 48,000 users defined… many of them spam… many of them dead… many redundant or no longer needed.
So how do we cleanup users?
Using the PHP panel I used this SQL script to select the users that have been registered but who have never ordered anything using Drupal6 Ubercart:
Special Offer for all NICKLITTEN Punters
20% Off with Coupon: NICKLITTEN
In Partnership with SNUG CBD - American readers get 20% off
CBD helps with relaxation, focus and great for pain relief. I highly recommend the SNUG CBD Tincture to help keep you in the zone when programming!
select count(*) from users where mail not in (select primary_email from uc_orders) and uid <> '0' and mail NOT LIKE "%drumstheword.com%" and mail NOT LIKE "%projex%"
note: do not touch uid=0 because this is the ANONYMOUS user and do not touch any *@drumstheword.com or *@projex.com users
This will give you a count value showing how many users are selected and if your ready to delete then just use:
delete from users where mail not in (select primary_email from uc_orders) and uid <> '0' and mail NOT LIKE "%drumstheword.com%" and mail NOT LIKE "%projex%"