def upgrade_environment(self, db): """Actually perform an environment upgrade. Implementations of this method should not commit any database transactions. This is done implicitly after all participants have performed the upgrades they need without an error being raised. """ success = True ver = dbhelper.get_system_value(self.env, dbkey) self.log.debug('Estimator about to upgrade from ver:%s' % ver) if ver < 1: self.log.debug('Creating Estimate and Estimate_Line_Item tables (Version 1)') success = success and dbhelper.execute_in_trans(self.env, ("""CREATE TABLE estimate( id integer PRIMARY KEY, rate DECIMAL, variability DECIMAL, communication DECIMAL, tickets VARCHAR(512), comment VARCHAR(8000) )""",[]), ("""CREATE TABLE estimate_line_item( id integer PRIMARY KEY, estimate_id integer, description VARCHAR(2048), low DECIMAL, high DECIMAL )""",[])) # SHOULD BE LAST IN THIS FUNCTION if success: dbhelper.set_system_value(self.env, dbkey, dbversion)
def upgrade_environment(self, db): """Actually perform an environment upgrade. Implementations of this method should not commit any database transactions. This is done implicitly after all participants have performed the upgrades they need without an error being raised. """ success = True ver = dbhelper.get_system_value(self.env, dbkey) self.log.debug('Estimator about to upgrade from ver:%s' % ver) if ver < 1: self.log.debug( 'Creating Estimate and Estimate_Line_Item tables (Version 1)') success = success and dbhelper.execute_in_trans( self.env, ("""CREATE TABLE estimate( id integer PRIMARY KEY, rate DECIMAL, variability DECIMAL, communication DECIMAL, tickets VARCHAR(512), comment VARCHAR(8000) )""", []), ("""CREATE TABLE estimate_line_item( id integer PRIMARY KEY, estimate_id integer, description VARCHAR(2048), low DECIMAL, high DECIMAL )""", [])) # SHOULD BE LAST IN THIS FUNCTION if success: dbhelper.set_system_value(self.env, dbkey, dbversion)
def upgrade(self): self.env.log.debug("T&E Checking for custom_report upgrade") # Check to see what version we have version = tryint(dbhelper.get_system_value(self.env, self.name)) if version > self.version: raise TracError( "Fatal Error: You appear to be running two plugins with" " conflicting versions of the CustomReportManager class." " Please ensure that '%s' is updated to " "version %s of the file reportmanager.py (currently using version %s)." % (__name__, str(self.version), str(version))) # Do the staged updates, I removed this: version < 1 and if not dbhelper.db_table_exists(self.env, 'custom_report'): dbhelper.execute_non_query( self.env, "CREATE TABLE custom_report (" "id INTEGER," "uuid VARCHAR(64)," "maingroup VARCHAR(255)," "subgroup VARCHAR(255)," "version INTEGER," "ordering INTEGER)") #if version < 2: # Updates complete, set the version dbhelper.set_system_value(self.env, self.name, self.version) self.env.log.debug("T&E END Checking for custom_report upgrade")
def upgrade(self): self.env.log.debug("T&E Checking for custom_report upgrade") # Check to see what version we have version = tryint(dbhelper.get_system_value(self.env, self.name)) if version > self.version: raise TracError("Fatal Error: You appear to be running two plugins with" " conflicting versions of the CustomReportManager class." " Please ensure that '%s' is updated to " "version %s of the file reportmanager.py (currently using version %s)." % (__name__, str(self.version), str(version))) # Do the staged updates, I removed this: version < 1 and if not dbhelper.db_table_exists(self.env, 'custom_report'): dbhelper.execute_non_query( self.env, "CREATE TABLE custom_report (" "id INTEGER," "uuid VARCHAR(64)," "maingroup VARCHAR(255)," "subgroup VARCHAR(255)," "version INTEGER," "ordering INTEGER)") #if version < 2: # Updates complete, set the version dbhelper.set_system_value(self.env, self.name, self.version) self.env.log.debug("T&E END Checking for custom_report upgrade")
def __init__(self): # Setup logging self.statuses_key = 'T&E-statuses' self.db_version_key = 'TimingAndEstimationPlugin_Db_Version' self.db_version = 8 # Initialise database schema version tracking. self.db_installed_version = dbhelper.get_system_value(self, \ self.db_version_key) or 0
def __init__(self): # Setup logging self.statuses_key = 'T&E-statuses' self.db_version_key = 'TimingAndEstimationPlugin_Db_Version' self.db_version = 6 # Initialise database schema version tracking. self.db_installed_version = dbhelper.get_system_value(self, \ self.db_version_key) or 0
def environment_needs_upgrade(self, db): """Called when Trac checks whether the environment needs to be upgraded. Should return `True` if this participant needs an upgrade to be performed, `False` otherwise. """ ver = dbhelper.get_system_value(self.env, dbkey) ans = (not ver) or (ver < dbversion) self.log.debug('Estimator needs upgrade? %s [installed version:%s pluginversion:%s '%(ans, ver, dbversion)) return ans
def environment_needs_upgrade(self, db): """Called when Trac checks whether the environment needs to be upgraded. Should return `True` if this participant needs an upgrade to be performed, `False` otherwise. """ ver = dbhelper.get_system_value(self.env, dbkey) ans = (not ver) or (ver < dbversion) self.log.debug( 'Estimator needs upgrade? %s [installed version:%s pluginversion:%s ' % (ans, ver, dbversion)) return ans
def upgrade_environment(self, db): """Actually perform an environment upgrade. Implementations of this method should not commit any database transactions. This is done implicitly after all participants have performed the upgrades they need without an error being raised. """ success = True ver = dbhelper.get_system_value(self.env, dbkey) ver = (ver and int(ver)) or 0 self.log.debug("Estimator about to upgrade from ver:%s" % ver) if ver < 1: self.log.debug("Creating Estimate and Estimate_Line_Item tables (Version 1)") success = success and dbhelper.execute_in_trans( self.env, ( """CREATE TABLE estimate( id integer PRIMARY KEY, rate DECIMAL, variability DECIMAL, communication DECIMAL, tickets VARCHAR(512), comment text )""", [], ), ( """CREATE TABLE estimate_line_item( id integer PRIMARY KEY, estimate_id integer, description VARCHAR(2048), low DECIMAL, high DECIMAL )""", [], ), ) # ver 2 might have left the database in an invalid state. if ver < 3: self.log.debug("Altering estimate adding diffcoment 2") success = success and dbhelper.execute_in_trans( self.env, (""" ALTER TABLE estimate ADD COLUMN diffcomment text ; """, []) ) if ver < 4: self.log.debug("Adding save date to estimates (Version 3)") success = success and dbhelper.execute_in_trans( self.env, (""" ALTER TABLE estimate ADD COLUMN saveepoch int ; """, []) ) # SHOULD BE LAST IN THIS FUNCTION if success: dbhelper.set_system_value(self.env, dbkey, dbversion)
def have_statuses_changed(self): """get the statuses from the last time we saved them, compare them to the ones we have now (ignoring '' and None), if we have different ones, throw return true """ s = dbhelper.get_system_value(self, self.statuses_key) if not s: return True sys_stats = get_statuses(self) s = s.split(',') sys_stats.symmetric_difference_update(s) sys_stats.difference_update(['', None]) return len(sys_stats) > 0
def have_statuses_changed(self): """get the statuses from the last time we saved them, compare them to the ones we have now (ignoring '' and None), if we have different ones, throw return true """ s = dbhelper.get_system_value(self.env, self.statuses_key) if not s: return True sys_stats = get_statuses(self.env) s = s.split(',') #self.env.log.debug('T&E: Statuses: stored:%r , sys:%r' %(s, sys_stats)) sys_stats.symmetric_difference_update(s) sys_stats.difference_update(['', None]) #self.env.log.debug('T&E: Statuses: diff:%r ' %(sys_stats, )) return len(sys_stats) > 0