How to ensure that database changes can be easily moved around DVCS with django

Overview

I am creating a website in django. I need to let people start adding flatpages and set some settings in admin. These changes must be final as this information comes from the client. However, I am also developing a backend, and as such will create and migrate tables. I am inserting these changes into a hub.

Instruments

django

git

south

postgres

Problem

How can I guarantee that I get database changes from an online site to me on my lappy, and also how can I push my database changes to a live site so that we have the minimum coordination needed? I am familiar with git hooks, so the option is in the game.

Application:

I think I know which tables can be modified using the administrator. Actually there should not be many overlappings. As I already reviewed, the danger is that I click data that will overwrite what they did.

Thanks.

+4
source share
3 answers

To get schema changes on the server, just use South. If you change a table, it may have data, make sure that you record both the migration of the schema and, if necessary, the migration of data in order to preserve the meaning of your data.

In order to return my updated data to you (which does not seem critical, but it may be nice to work with current test data as it develops), I usually just use Django tools and dumpdates and loaddata commands. It's simple enough to dump the fixture and pass it to your repo, and then loaddata at your end.

You can try using git hooks to automate some of them, but if you want to automate, I recommend trying something like Fabric. Most of this stuff should not be triggered every time you push / pull (in particular, I usually don't want to unload a new data binding often).

+2
source

You should probably look south:

http://south.aeracode.org/

It seems to me that you could create a git hook that runs south if you are implementing some kind of continuous integration system.

Otherwise, each time you click, you will have to manually complete the migration steps yourself. Do not forget to put the message "site for maintenance" .;)

+2
source

I recommend that you use mk-table-sync to pull the changes from the live server to your laptop. mk-table-sync accepts many parameters, so you can automate this process using fabric . Basically, you will create a function that executes mk-table-sync on every tablet that you want to pull from the server.

This means that you cannot change the dabatase parameters yourself, because they will be overwritten by pressing.

The only changes you make to the live database are the use of the South. You push the code to the server and then run migrate to update the database schema.

0
source

All Articles