BASH HEAD! Errr... I mean, database.

Post date 2012-06-24
Category Digital

When you develop a lot of sites you need to get a good workflow in. There are the basics of course:

I really dig handling deployment and version control with GIT - but that only applies to files. So what do you do with databases, especially if you're multiple people working on one project? The best I got so far is a workflow that goes a little something like this:

Back at Good Old we had a really handy script written by Hugo Wetterberg, awesomeguy extraordinaire, that fetched the database from a remote server and imported it into your local environment automagically. I really missed this when I left the company, so I learnt some basic bash scripting that does the very same thing. As long as you've got SSH access to a server (and that SSH user has access to mysql) you can use this script to download and automatically import a database:

Mind you, I only know rudimentary bash stuff - this could probably be way more elegant. For instance, it opens a new connection every time a new command needs to be given to the server - prompting you for your SSH password every time if you don't use SSH keys. But it works, and thus I'm happy.