Skip to content

Instantly share code, notes, and snippets.

View CNanninga's full-sized avatar

Chris Nanninga CNanninga

View GitHub Profile
@CNanninga
CNanninga / magento1-anonymize.sql
Created September 9, 2019 13:58
Anonymize Magento 1 database
# admin emails
UPDATE admin_user AS tb SET tb.email = CONCAT('customer', tb.user_id, '@mailinator.com');
# 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
@CNanninga
CNanninga / magento1-clone-prod-to-stage.sh
Last active July 18, 2019 14:22
Magento 1 Clone Prod to Stage
#!/bin/bash
SOURCE_ROOT_DIR="/var/www"
SOURCE_DUMP_FILENAME=example_prod_$(date +%F).sql.gz
TARGET_DB_NAME="example_prod"
TARGET_DB_HOST="localhost"
TARGET_DB_USER="example"
TARGET_DB_PASS="example"
TARGET_ROOT_DIR="/var/www"
@CNanninga
CNanninga / minify-magento2.sql
Created January 8, 2019 14:39
Minify a Magento 2 database
-- ----------------------------------
select "Deleting all but 50 customers" debug;
drop procedure if exists minify_customers;
delimiter #
create procedure minify_customers()
begin
select @remaining_customers := count(*) from `customer_entity`;
while @remaining_customers > 50 do
@CNanninga
CNanninga / minify-magento1.sql
Created January 8, 2019 14:37
Minify a Magento 1 database
-- ----------------------------------
select "Deleting all but 50 customers" debug;
drop procedure if exists minify_customers;
delimiter #
create procedure minify_customers()
begin
select @remaining_customers := count(*) from `customer_entity`;
while @remaining_customers > 50 do

Valet+ Configuration

Before Valet Install

Kill Native PHP and MySQL

brew services stop php
brew services stop mysql
@CNanninga
CNanninga / magento2-clone-prod-to-stage.sh
Last active August 27, 2019 07:00
Magento 2 Production to Stage Clone
#!/bin/bash
SOURCE_DB_NAME="example_prod"
SOURCE_ROOT_DIR="/var/www/prod"
SOURCE_DUMP_FILENAME=example_prod_$(date +%F).sql.gz
TARGET_DB_NAME="example_stage"
TARGET_ROOT_DIR="/var/www/stage"
TARGET_SSH_USER="www-stage"
TARGET_SSH_HOST="stage.example.com"