I set up MAMP on my machine to develop some website stuff, and since I wanted to separate out my projects in an organized manner I set up virtual hosts for each one, which is working. I have my web files (javascripts, css, html, php ) for each project in a directory such as /Users/Alex/Dropbox/code/projectX/. My MAMP directory is otherwise identical to how it was out-of-the-box; all Mysql stuff is in /Applications/MAMP/db. \projectX\ is already a git repository, but my db files are not version controlled.
Question: how do I version control the database associated with each web project? I have three approaches in my head, and am not sure how implement the first two. I prefer the first one because it seems simpler and fits in with the virtual hosts scheme nicely.
a) Move the database directory for projectX into \projectX\ folder and then just git add it. I do not know how to tell MySQL that I have this database here and that database there, though.
b) Somehow tell git that it also needs to version control Applications\MAMP\db\mysql\projectXdb as if it were inside \projectX\
c) Don’t be fancy and just have a separate repository for the databases.
First, I would read this and the links he posts to — simply because they are a good read.
In short (and this is where I may be misunderstanding the question), I don’t think it’s ever the wisest to store the actual database into version control ever. Rather, you will need to decide on some system of storing database scripts which control/alter/set the database. Thus, these scripts can be stored absolutely anywhere within your code’s file structure.
If this idea works, then you don’t have to change the location of the actual database, and git doesn’t have to care where the actual database is either.
An example of what I’m suggesting would be to make a file like this:
And then store that into some directory called
/Users/Alex/Dropbox/code/projectX/db-scriptsor something. Within that directory would be all the scripts needed to manage/replicate your DB at any moment.EDIT:
If the software keeps all information in the DB itself, then perhaps run
mysqldump(or equivilant) and store that script into the code.Storing the textual version allows two things:
a) It’s more effective/efficient than storing binary files (if I understand RCS/git correctly)
b) git can do diffs and grep-searches on the files. (Which might not matter if there is already another tool doing that)