python::schema_migrator Namespace Reference


Functions

def migrate


Function Documentation

def python::schema_migrator::migrate (   manager  ) 

Migrate manager and all its dependents to the current schema version.

This module is responsible for migrating projects as the stored
schema evolve.  It does this simply by calling the manager's
WriteFamily() method so that all the optional data members (those
with '+' or '-' qualifiers in the call to ioh in _DoMemberIO(ioh)
will synchronise with the current version.  This will allow the
eventual removal of these qualifiers.

Definition at line 18 of file schema_migrator.py.

00018                     :
00019 
00020     """Migrate manager and all its dependents to the current schema version.
00021 
00022     This module is responsible for migrating projects as the stored
00023     schema evolve.  It does this simply by calling the manager's
00024     WriteFamily() method so that all the optional data members (those
00025     with '+' or '-' qualifiers in the call to ioh in _DoMemberIO(ioh)
00026     will synchronise with the current version.  This will allow the
00027     eventual removal of these qualifiers."""
00028 
00029     min_ver = 0
00030     cur_ver = 1
00031     man_ver = manager.GetSchemaVersion()
00032     if ( man_ver < min_ver ):
00033         print "\nSorry, Manager :-\n\n" + str(manager)
00034         print "\nhas a schema version that is too old to migrate to the current version " + str(cur_ver)
00035         print "PLease check the table below to find a version of GBS that can migrate your version on."
00036         print history
00037         sys.exit(1)
00038     if ( man_ver > cur_ver ):
00039         print "\nSomething is wrong! The current schema version is " + str(cur_ver)
00040         print "but the manager has a later version:-\n\n" + str(manager)
00041         print "\nHere is the recorded schema history:-"
00042         print history
00043         print "Please investigate!"
00044         sys.exit(1)
00045     if ( man_ver == cur_ver):
00046         print "The schema version (%d) is up to date" % cur_ver
00047         return
00048     print "\nMigrating data structure schema %d -> %d please wait ...." % (man_ver,cur_ver)
00049     manager.WriteFamily()
00050     print "Migration complete"
00051     manager._SetSchemaVersion(cur_ver)
    manager._SetSchemaVersion(cur_ver)


Generated on Fri Mar 5 09:25:42 2010 for gbs by  doxygen 1.4.7