views:

562

answers:

7

Hi, I'm work on project with django framework and use control version system to synchronize my code with other peoples. But i don't know how organize work with database. In django, any people, worked on project, may changes django models, and tell 'syncdb' to synchronize model objects with db. But other people don't about this changes, and it's code revision may not works. Please, tell me some ways to solve this problem (maybe, different db or something another).

Thanks, and excuse my english :)

+2  A: 

You have to actually talk to the people on your project.

If someone changes any database model, they have to actually tell everyone else about the change. This is not a Django problem.

Think of any SQL database -- without Django. When the DBA drop's a table, they have to tell everyone that they changed the database. Otherwise all programs that use the table break.

The model definition is special, and whoever can change this must tell everyone else.

S.Lott
A: 

Sounds like you want migrations.

As an example: http://www.aswmc.com/dbmigration/

You may also want to add functional unit tests that actually test that the schema is as expected, that way when the tests fail, you can see that it is a schema change, and audit whether it will affect other parts of the app. If it doesn't, fix your test to take into account the new schema.

ashchristopher
That is what `syncdb` does. His problem is that the programmers forget to run it.
Christian Vest Hansen
It sounds like they have an existing database dump, and when the schema changes, they database becomes inconsistent. Sounds like he wants a way to make sure the database stays consistent... this migrations + functional tests. Functional tests force the users to actively figure out whats wrong.
ashchristopher
+2  A: 

You must have an initial backup of the DB under verison control. And after that you have to put all the modification scripts on the same version control. Something like this:

/Database (in the repository)

  • Initial backup
  • Script1_date.sql
  • Script2_date.sql

...

Mariano
This is essentially db migrations.
ashchristopher
+1  A: 

I'm not sure to understand your problem; but remember that on Django, syncdb only creates new tables. It doesn't alter an existing table.

If, for example you just add a new field, a syncdb won't do anything.

Javier
+1  A: 

Hi! I'm curious...what happens if you put your MDF and LDF files under source control? Of course if your tables are empty and you just have the structure of the database...

Cheers from Argentina!

pabloide86
MDFs are binary files, so you can't really diff them to see the changes between revisions...
Mauricio Scheffer
+1  A: 

Actually, looking at the alternatives, I'm often surprised that nobody mentions South

http://south.aeracode.org/

It seems to be the best migration app out there... perhaps I am missing something important, but I find it pretty nice to work with...

chiggsy
A: 

hi, take also a look at deltasql. you can test it at http://www.gpu-grid.net/deltasql (username: admin password: testdbsync ) and download from http://sourceforge.net/projects/deltasql ciao :-)