stechico
5/31/2013 - 8:27 AM

Git: Useful if you are doing dev between multiple machines (e.g. local or dev environments). Based on "Synchronizing a MySQL Database with G

Git: Useful if you are doing dev between multiple machines (e.g. local or dev environments). Based on "Synchronizing a MySQL Database with Git and Git Hooks" > http://ben.kulbertis.org/2011/10/synchronizing-a-mysql-database-with-git-and-git-hooks/

Note: I'm using the following in OSX.

#!/bin/sh
mysqldump -h localhost -u [mysql_user] -p[mysql_password] --skip-extended-insert [database] | gzip > /path/to/your/repo/[database].sql.gz
cd /path/to/your/repo/
git add [database].sql.gz
 
# Note:
# No need to have these comments in the file...
# This file's location @ /path/to/your/repo/.git/hooks/pre-commit
# Be sure to make this file executable via:
# sudo chmod +x /path/to/your/repo/.git/hooks/pre-commit
#!/bin/sh
cd /path/to/your/repo/
gunzip -v < [database].sql.gz |  mysql -u [mysql_user] -p[mysql_password] [database]
 
# Note:
# No need to have these comments in the file...
# This file's location @ /path/to/your/repo/.git/hooks/post-merge
# Be sure to make this file executable via:
# sudo chmod +x /path/to/your/repo/.git/hooks/post-merge