Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: Export MySQL database on commit?

Tags:

git

mysql

export

Is there a way I can utilize git to export/download my MySQL development database that is utilized in my code on a commit or some other way through git so that whenever I clone my project, I always have a current copy of the database?

If not, I can always export the database, and add it to the source, I was just wondering if git had the capability of doing this almost like a hook.

like image 326
drewrockshard Avatar asked Jan 21 '11 22:01

drewrockshard


1 Answers

I ended up using the git hooks as I anticipated. I created the pre-commit hook and added the following to it:

#!/bin/bash
DBUSER="sysbackup"
DBPASS="password"
DB="database-name"
SCHEMAPATH="DBSchema"

mysqldump -u $DBUSER -p$DBPASS $DB > $SCHEMAPATH/$DB.sql
git add $SCHEMAPATH/$DB.sql
exit 0
like image 155
drewrockshard Avatar answered Oct 14 '22 08:10

drewrockshard