Skip to content

Instantly share code, notes, and snippets.

@mhhansen
Last active November 12, 2019 21:14
Show Gist options
  • Save mhhansen/f9abecafde90946c19b2ad1741259ea4 to your computer and use it in GitHub Desktop.
Save mhhansen/f9abecafde90946c19b2ad1741259ea4 to your computer and use it in GitHub Desktop.
Magento 1 - Anonymize db
# Customers
UPDATE customer_entity AS tb SET tb.email = CONCAT('customer', tb.entity_id, '@mailinator.com');
# Newsletter Subscribers
UPDATE newsletter_subscriber AS tb SET tb.subscriber_email = REPLACE (tb.subscriber_email,(SUBSTRING_INDEX(SUBSTR(tb.subscriber_email, INSTR(tb.subscriber_email, '@') + 1),'.',5)), 'mailinator.com');
# Sales Flat Orders
UPDATE sales_flat_order AS tb SET tb.customer_email = REPLACE (tb.customer_email,(SUBSTRING_INDEX(SUBSTR(tb.customer_email, INSTR(tb.customer_email, '@') + 1),'.',5)), 'mailinator.com');
# Sales Flat Orders Address
UPDATE sales_flat_order_address AS tb SET tb.email = REPLACE (tb.email,(SUBSTRING_INDEX(SUBSTR(tb.email, INSTR(tb.email, '@') + 1),'.',5)), 'mailinator.com');
# Sales Flat Quotes
UPDATE sales_flat_quote AS tb SET tb.customer_email = REPLACE (tb.customer_email,(SUBSTRING_INDEX(SUBSTR(tb.customer_email, INSTR(tb.customer_email, '@') + 1),'.',5)), 'mailinator.com');
# core email queue recipients
UPDATE core_email_queue_recipients AS tb SET tb.recipient_email = REPLACE (tb.recipient_email,(SUBSTRING_INDEX(SUBSTR(tb.recipient_email, INSTR(tb.recipient_email, '@') + 1),'.',5)), 'mailinator.com');
# bronto newsletter
UPDATE bronto_newsletter_queue AS tb SET tb.subscriber_email = REPLACE (tb.subscriber_email,(SUBSTRING_INDEX(SUBSTR(tb.subscriber_email, INSTR(tb.subscriber_email, '@') + 1),'.',5)), 'mailinator.com');
# bronto email capture
UPDATE bronto_emailcapture_queue AS tb SET tb.email_address = REPLACE (tb.email_address,(SUBSTRING_INDEX(SUBSTR(tb.email_address, INSTR(tb.email_address, '@') + 1),'.',5)), 'mailinator.com');
TRUNCATE dataflow_batch_export;
TRUNCATE dataflow_batch_import;
TRUNCATE log_customer;
TRUNCATE log_quote;
TRUNCATE log_summary;
TRUNCATE log_summary_type;
TRUNCATE log_url;
TRUNCATE log_url_info;
TRUNCATE log_visitor;
TRUNCATE log_visitor_info;
TRUNCATE log_visitor_online;
TRUNCATE report_viewed_product_index;
TRUNCATE report_compared_product_index;
TRUNCATE report_event;
TRUNCATE index_event;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment