开发者

Git: Export MySQL database on commit?

开发者 https://www.devze.com 2023-02-06 06:05 出处:网络
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 projec开发者_开发技巧

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 projec开发者_开发技巧t, 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.


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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号