views:

144

answers:

3

Overview

I'm building a website in django. I need to allow people to begin to add flatpages, and set some settings in the admin. These changes should be definitive, since that information comes from the client. However, I'm also developing the backend, and as such will am creating and migrating tables. I push these changes to the hub.

Tools

django

git

south

postgres

Problem

How can I ensure that I get the database changes from the online site down to me on my lappy, and also how can I push my database changes up to the live site, so that we have a minimum of co-ordination needed? I am familiar with git hooks, so that option is in play.

Addendum:

I guess I know which tables can be modified via the admin. There should not be much overlap really. As I consider further, the danger really is me pushing data that would overwrite something they have done.

Thanks.

A: 

You should probably take a look at South:

http://south.aeracode.org/

It seems to me that you could probably create a git hook that triggers off South if you are doing some sort of continuous integration system.

Otherwise, every time you do a push you will have to manually execute the migration steps yourself. Don't forget to put up the "site is under maintenance" message. ;)

GrumpyCanuck
I mentioned south in my original post. Using it.
chiggsy
oops, didn't see that when I originally read the question.
GrumpyCanuck
A: 

Hey Chiggsy,

I recommend that you use mk-table-sync to pull changes from live server to your laptop. mk-table-sync takes a lot of parameters so you can automate this process by using fabric. You would basically create a fabric function that executes mk-table-sync on each tablet that you want to pull from the server.

This means that you can not make dabatase changes yourself, because they will be overwritten by the pull.

The only changes that you would be making to the live database are using South. You would push the code to the server and then run migrate to update the database schema.

tarasm
mk-table-sync is mysql only, which I am not using. Unless I missed something. Fabric interesting, but unsure if i prefer it over git hooks, which I can run via HTTP... considering. Thx
chiggsy
Right, I forgot that mk-table-sync is mysql only.Do you need to push content changes from your system to live server and pull from live server to your system?
tarasm
+1  A: 

For getting your schema changes up to the server, just use South carefully. If you modify any table they might have data in, make sure you write both a schema migration and as necessary a data migration to preserve the sense of their data.

For getting their updated data back down to you (which doesn't seem critical, but might be nice to work with up-to-date test data as you're developing), I generally just use Django fixtures and the dumpdata and loaddata commands. It's easy enough to dump a fixture and commit it to your repo, then a loaddata on your end.

You could try using git hooks to automate some of this, but if you want automation I do recommend trying something like Fabric instead. Much of this stuff doesn't need to be run every single time you push/pull (in particular, I usually wouldn't want to dump a new data fixture that frequently).

Carl Meyer