Package gavo :: Package user :: Module upgrade
[frames] | no frames]

Module upgrade

source code

Stuff dealing with the upgrade of the database schema.

From software version 0.8.2 on, there is a dc.metastore table with a key schemaversion. Each change in the central schema increases the value (interpreted as an integer) by one, and this module will contain a corresponding upgrader.

An upgrader inherits form the Upgrader class. See there for more details.

This module contains the current schemaversion expected by the software; gavo upgrade does everything required to bring the what's in the database in sync with the code (or so I hope).

Classes
  AnnotatedString
a string with an annotation.
  Upgrader
A specification to upgrade from some schema version to another schema version.
  To0Upgrader
This is executed when there's no schema version defined in the database.
  To1Upgrader
  To2Upgrader
  To3Upgrader
  To4Upgrader
  To5Upgrader
  To6Upgrader
  To7Upgrader
  To8Upgrader
  To9Upgrader
  To10Upgrader
  To11Upgrader
  To12Upgrader
  To13Upgrader
  To14Upgrader
  To15Upgrader
  To16Upgrader
  To17Upgrader
  To18Upgrader
  To19Upgrader
  To20Upgrader
Functions
 
getColumnNamesFor(tableId, connection)
returns (normalised) column names for tableId.
source code
 
relationExists(tableName, connection)
returns True if tableName (as schema.name) exists, False otherwise.
source code
 
showProgress(msg)
outputs msg to stdout without lf "immediately".
source code
 
getDBSchemaVersion()
returns the schemaversion given in the database.
source code
 
dumpExtensionUpdater(conn)
prints SQL to bring [db]managedExtensions up to date.
source code
 
iterStatements(startVersion, endVersion=20, upgraders=None)
yields all upgraders from startVersion to endVersion in sequence.
source code
 
upgrade(forceDBVersion=None)
runs all updates necessary to bring a database to the CURRENT_SCHEMAVERSION.
source code
 
parseCommandLine() source code
 
main() source code
Variables
  CURRENT_SCHEMAVERSION = 20
  __package__ = 'gavo.user'
Function Details

getColumnNamesFor(tableId, connection)

source code 

returns (normalised) column names for tableId.

(tableId is something like //tap#tables)

getDBSchemaVersion()

source code 

returns the schemaversion given in the database.

This will return -1 if no schemaversion is declared.

upgrade(forceDBVersion=None)

source code 

runs all updates necessary to bring a database to the CURRENT_SCHEMAVERSION.

Unless catastrophic things go on, each upgrade is a transaction of its own; the first failed transaction stops the upgrade at the version last successfully upgraded to.