wiki:UpgradeProcedures

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/manange.py 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/manage.py 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/manage.py test <some-descriptive-name>.py --url postgres://localhost:5432/dbtest
    
  5. Commit when everything tests OK.
    python migration/manage.py commit <some-descriptive-name>.py
    
  6. Upgrade core database
    python migration/manage.py upgrade --url=postgres://localhost:5432/qqq
    
Last modified 9 years ago Last modified on Jul 10, 2008 2:44:57 PM