Skip to content

Instantly share code, notes, and snippets.

Zach Adams zach-adams

Block or report user

Report or block zach-adams

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@zach-adams
zach-adams / wp-modifydb.php
Created Aug 31, 2016 — forked from jcanfield/wp-modifydb.php
Serialized PHP Search and Replace
View wp-modifydb.php
<?php
/**
*
* Safe Search and Replace on Database with Serialized Data v2.0.1
*
* This script is to solve the problem of doing database search and replace when
* developers have only gone and used the non-relational concept of serializing
* PHP arrays into single database columns. It will search for all matching
* data on the database and change it, even if it's within a serialized PHP
* array.
@zach-adams
zach-adams / MysqlDatabase.php
Last active Jun 22, 2016
Backup Manager with Include/Ignore tables
View MysqlDatabase.php
<?php namespace App\Backups;
use BackupManager\Databases\Database;
/**
* Class MysqlDatabase
* @package BackupManager\Databases
*/
class MysqlDatabase implements Database {
@zach-adams
zach-adams / vagrant_halt_custom
Created Jul 15, 2015
A copy of the db_backup script that automatically copies the backups to the sync folder
View vagrant_halt_custom
#!/bin/bash
#
# Create individual SQL files for each database. These files
# are imported automatically during an initial provision if
# the databases exist per the import-sql.sh process.
mysql -e 'show databases' | \
grep -v -F "information_schema" | \
grep -v -F "performance_schema" | \
grep -v -F "mysql" | \
grep -v -F "test" | \
@zach-adams
zach-adams / sync-sql.sh
Created Jul 15, 2015
A copy of import-sql.sh with edits to refresh databases on vagrant up
View sync-sql.sh
#!/bin/bash
#
# Sync the sql files in the sync folder
#
# The files in the {vvv-dir}/database/sync/ directory should be created by
# mysqldump or some other export process that generates a full set of SQL commands
# to create the necessary tables and data required by a database.
#
# For a sync to work properly, the SQL file should be named `db_name.sql` in which
# `db_name` matches the name of a database already created in {vvv-dir}/database/init-custom.sql
@zach-adams
zach-adams / Vagrantfile
Last active Apr 13, 2018
A modified Vagrantfile to tell VVV to run import-sql script on up
View Vagrantfile
# Vagrant Triggers
#
# If the vagrant-triggers plugin is installed, we can run various scripts on Vagrant
# state changes like `vagrant up`, `vagrant halt`, `vagrant suspend`, and `vagrant destroy`
#
# These scripts are run on the host machine, so we use `vagrant ssh` to tunnel back
# into the VM and execute things. By default, each of these scripts calls db_backup
# to create backups of all current databases. This can be overridden with custom
# scripting. See the individual files in config/homebin/ for details.
if defined? VagrantPlugins::Triggers
You can’t perform that action at this time.