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?
有没有办法可以利用git导出/下载我的MySQL开发数据库,这个数据库在我的代码中通过提交或其他方式通过git使用,这样每当我克隆我的项目时,我总是拥有数据库的当前副本?
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.
如果没有,我总是可以导出数据库,并将其添加到源代码,我只是想知道git是否有能力这样做几乎像一个钩子。
1 个解决方案
#1
16
I ended up using the git hooks as I anticipated. I created the pre-commit
hook and added the following to it:
我最终按照我的预期使用了git hooks。我创建了预提交钩子并添加了以下内容:
#!/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
#1
16
I ended up using the git hooks as I anticipated. I created the pre-commit
hook and added the following to it:
我最终按照我的预期使用了git hooks。我创建了预提交钩子并添加了以下内容:
#!/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