Database Upgrade Proceduress

This section details switching databases, upgrading existing database and migrating database schema changes.

Schema Changes

The bisque system uses Migrate to control schema changes.

This system adds a small version table to the controlled database and manages upgrdade-downgrage scripts.

  1. Ensure migrate is installed. There is a packaged version in the suggested directory.
    migrate help
    If not found, then move to the suggested directory
    easy_install sqlaclhemy-migrate
  2. Testing the version of the database (from the TG directory).
    python migration/ version

Modify the schema

All Scripts previously placed under management are contained in the migration/versions directory. These should *never* be modified directly.

  1. Create a new version script
    python migration/ script <some-descriptive-name>.py
  2. Edit <some-descriptive-name>.py adding upgrade/dowgrade Procedures.
    It is best to simple add the tables that need to be changed instead of import the model i.e
    meta = MetaData(migrate_engine)
    tb = Table ('dbtable', meta, autoload=True) 
  3. Create a test database
    1. postgres -- copy your existing database to a test
      pg_dump -Fc qqq  > /tmp/db.dump
      createdb dbtest 
      pg_restore -d dbtest /tmp/db.dump
  4. Test your script on the test database
    python migration/ test <some-descriptive-name>.py --url postgres://localhost:5432/dbtest
  5. Commit when everything tests OK.
    python migration/ commit <some-descriptive-name>.py
  6. Upgrade core database
    python migration/ upgrade --url=postgres://localhost:5432/qqq
Last modified 10 years ago Last modified on 07/10/2008 02:44:57 PM