I want to “synchronize” a mysql database (and not just the schema) with all git commits and checkouts (probably via hooks) in Linux/BSD/Unix enviornment.
[Useful when controlling the entire presentation + content of a mysql-based web site/application, and other mysql applications, as the code for said sites/applications are under development, and/or to “rev control” the entire website. Presumably useful for pushing “copies” (exclusively via git) of small, relatively-static websites to various test/production servers that each have separate, independent mysql servers.]
Potential design/workflow: a git commit dumps a mysql database and adds said database (in a .sql file) to the commit (probably via a pre-commit hook). A subsequent git checkout imports said .sql file (from the current git branch) to the database (probably via a post-commit hook), hence “synchronized” with the git commit/branch. This basically rev-controls the entire database, synchronizing each database rev to a git commit.
How to implement this?
My WordPress-database-control example follows.
./dbase-baseurl-set.sh $baseurlneeded to tell WordPress which host it’s on–WP unfortunately not that modular../dbase-baseurl-set.shruns from the top level of the working tree.git commit -n [...]to avoid executing thepre-commithook. (Potentially useful when first-time adding/committingdabase-dump.sql.gz.)Example Ubuntu session:
Contents of
dbase-baseurl-set.sh(note said file was edited from its original for best presentation, unlikely it introduced bugs, but still possible):