Thursday, June 02, 2005

Back to Oracle

Category: UpgradingOracleDatabases

In Extreme Programming Explained (2nd edition), Kent Beck references Pramod Sadalage's elegant incremental design strategy:

  • Start with an empty database.

  • Add all the tables and columns with automated scripts that also migrate any existing data as necessary.

  • Sequentially number the scripts so a database at any earlier stage can be brought up to any later stage by running the scripts.



This idea is extremely (pun intended) similar to my own thoughts on the same problem, though I think it misses a couple of points. I'd prefer to see it written more like:


  • Start with an empty database.

  • Add all the tables and columns you need for the current piece of work with automated scripts that also migrate any existing data as necessary.

  • Surround each script in tests that cover the pre and post conditions. The pre conditions cover your assumptions about the database required for the script to run, the post conditions cover the requirements for regarding the script as 'complete'

  • Sequentially number the scripts so a database at any earlier stage can be brought up to any later stage by running the scripts.

  • Make sure a failure in any script (including its pre or post) stops the rest of the patches from running

  • Make sure you can run all the patches from a single command




If the system you're developing sits on top of a legacy system then your build will start with an import of a set of live data into an empty schema, the upgrade as covered above and then the tests for the rest of the application can run against a system that closely mirrors the target environment.
If the live data is so huge it takes to long to do the upgrade as part of the regular build you've got three options:

  • Tune the upgrade so that it is quick enough

  • Reduce the set of data you import so you have the right texture of data on a smaller scale

  • Run the full import and upgrade in a less frequent build



Ok, ok, so it might not be so elegant as Pramod's way of putting it, but it's complete...

Aside: If you've not read XP Explained, read it NOW. If you've read the first edition, but not the second, read the second edition NOW. If you've read both, think about reading them both again!


Technorati Tags: , , ,

0 Comments:

Post a Comment