Created
January 9, 2017 20:43
-
-
Save mttjohnson/7b05110a7d72f1d29f2ad58d94873192 to your computer and use it in GitHub Desktop.
email cleanup sql
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
' replace mydomainnamehere.com | |
' replace db_name_here | |
use information_schema; | |
SET SESSION group_concat_max_len=10000000; | |
select | |
group_concat( | |
concat('UPDATE `',`table_name`,'` SET `',`column_name`,'` = REPLACE(`',`column_name`,'`, SUBSTRING(`',`column_name`,'`, LOCATE(''@'', `',`column_name`,'`)), CONCAT(''+'', SUBSTRING(MD5(SUBSTRING(`',`column_name`,'`, LOCATE(''@'', `',`column_name`,'`))) FROM 1 FOR 6), ''@example.com'')) WHERE `',`column_name`,'` NOT LIKE ''%@mydomainnamehere.com'';') SEPARATOR '\n\n') as q | |
from `columns` as c | |
where | |
table_schema = 'db_name_here' /* UPDATE DATABASE NAME */ | |
and ( | |
(`column_name` like '%email%' and `data_type` in ('varchar', 'text')) | |
or (`table_name` like '%core_config_data' and `column_name` = 'value') | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment