jon3k wrote:
You also make a good point about seperate databases, just not sure of a good way to keep them synchronized - any recommendations?
There are a number of techniques. Database replication is not one of them.
The easiest way to start with, it to simply maintain your database structure as a script containing DDL CREATE statements, and each time it changes, each developer drops their database and reloads it from the create script.
However, that is inconvenient, and doesn't work in a production environment where you want to make changes to the structure while keeping existing data.
Normally I have two sets of scripts
- A create script, containing DDL to create the database from fresh (Possibly some INSERTs too to add initial data)
- A set of modification scripts, in chronological order
Each time a developer wants to make a database change, they make the change in both the create script, AND make a modification script for it.
This might be able to be done automatically by using one of the many SQL diff programs to compare the schema of the old and new DBs, and make ALTER scripts for you.
All of these scripts would of course be kept in SVN - when A modify script is no longer needed (perhaps because a subsequent refactoring dropped the table it was modifying), it can be deleted.
Moreover, modify scripts can be deleted once you're sure that they've been run on every instance of the application in existence (Production is usually the last one to be updated, unless some of the developers are on holiday at the time).
It's a pain in the arse, but it's the only real way to sort it out.
Clearly you can't have multiple developers sharing a database, as they'd tread on each others toes - if I dropped a column, and removed all code that uses it, other developers' working copies would not yet have that code removed (until I committed it).
Another minor problem is when you decide to revert some changes, you have to switch back to an older version of the DB - but usually the developers figure this out on a case-by-case basis.
Mark