Created
April 14, 2015 10:17
-
-
Save wesamly/b5443ee183d670a6f3cd to your computer and use it in GitHub Desktop.
Git mysql schema on project commits
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
#!/bin/sh | |
#path to script: /path_to_git_repo/.git/hooks/pre-commit | |
#DB Details | |
DBHOST=localhost | |
DBUSER=myuser | |
DBPASS=mypass | |
DBNAME=test_dbname | |
#Path to mysqldump | |
MYSQLDUMP=/Applications/MAMP/Library/bin/mysqldump | |
#Path to repository | |
GITREPO=/Applications/MAMP/htdocs/gitwithdb | |
cd $GITREPO | |
#Where to save the sql file | |
mkdir -p $GITREPO/sqlSchema/ | |
$MYSQLDUMP --compact --user=$DBUSER -p$DBPASS -d $DBNAME > $GITREPO/sqlSchema/schema.sql | |
git add sqlSchema/schema.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Applied from this StackOverflow answer: http://stackoverflow.com/a/5518976/249645