Example #1
0
    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.
        """
        def p(s):
            print s
            return True
        print "Timing and Estimation needs an upgrade"
        p("Upgrading Database")
        self.do_db_upgrade()
        p("Upgrading reports")
        self.do_reports_upgrade(force=self.have_statuses_changed())

        #make sure we upgrade the statuses string so that we dont need to always rebuild the
        # reports
        stats = get_statuses(self)
        val = ','.join(list(stats))
        dbhelper.set_system_value(self, self.statuses_key, val)

        if self.ticket_fields_need_upgrade():
            p("Upgrading fields")
            self.do_ticket_field_upgrade()
        if self.needs_user_man():
            p("Upgrading usermanual")
            self.do_user_man_update()
        print "Done Upgrading"
    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")
Example #3
0
 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)
Example #4
0
    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.
        """
        def p(s):
            print s
            return True

        print "Timing and Estimation needs an upgrade"
        p("Upgrading Database")
        self.do_db_upgrade()
        p("Upgrading reports")
        self.do_reports_upgrade(force=self.have_statuses_changed())

        #make sure we upgrade the statuses string so that we dont need to always rebuild the
        # reports
        stats = get_statuses(self)
        val = ','.join(list(stats))
        dbhelper.set_system_value(self, self.statuses_key, val)

        if self.ticket_fields_need_upgrade():
            p("Upgrading fields")
            self.do_ticket_field_upgrade()
        if self.needs_user_man():
            p("Upgrading usermanual")
            self.do_user_man_update()
        print "Done Upgrading"
  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")
Example #6
0
 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)
Example #7
0
    def do_db_upgrade(self):
        self.log.debug( "T&E Beginning DB Upgrade");
        if self.db_installed_version < 1:
            if not dbhelper.db_table_exists(self.env, 'bill_date'):
                print "Creating bill_date table"
                sql = """
                CREATE TABLE bill_date (
                time integer,
                set_when integer,
                str_value text
                );"""
                dbhelper.execute_non_query(self.env,  sql)

        if self.db_installed_version < 5:
            # In this version we convert to using reportmanager.py
            # The easiest migration path is to remove all the reports!!
            # They will be added back in later but all custom reports will be lost (deleted)
            if dbhelper.db_table_exists(self.env, 'report_version'):
                print "Dropping report_version table"
                sql = "DELETE FROM report " \
                      "WHERE author=%s AND id IN (SELECT report FROM report_version)"
                dbhelper.execute_non_query(self.env, sql, 'Timing and Estimation Plugin')

                sql = "DROP TABLE report_version"
                dbhelper.execute_non_query(self.env, sql)

        #version 6 upgraded reports

        # This statement block always goes at the end this method
        dbhelper.set_system_value(self.env, self.db_version_key, self.db_version)
        self.db_installed_version = self.db_version
        self.log.debug( "T&E End DB Upgrade");
    def do_db_upgrade(self):
        self.log.debug( "T&E Beginning DB Upgrade");
        if self.db_installed_version < 1:
            if not dbhelper.db_table_exists(self.env, 'bill_date'):
                print "Creating bill_date table"
                sql = """
                CREATE TABLE bill_date (
                time integer,
                set_when integer,
                str_value text
                );"""
                dbhelper.execute_non_query(self.env,  sql)

        if self.db_installed_version < 5:
            # In this version we convert to using reportmanager.py
            # The easiest migration path is to remove all the reports!!
            # They will be added back in later but all custom reports will be lost (deleted)
            if dbhelper.db_table_exists(self.env, 'report_version'):
                print "Dropping report_version table"
                sql = "DELETE FROM report " \
                      "WHERE author=%s AND id IN (SELECT report FROM report_version)"
                dbhelper.execute_non_query(self.env, sql, 'Timing and Estimation Plugin')

                sql = "DROP TABLE report_version"
                dbhelper.execute_non_query(self.env, sql)

        #version 6 upgraded reports

        # This statement block always goes at the end this method
        dbhelper.set_system_value(self.env, self.db_version_key, self.db_version)
        self.db_installed_version = self.db_version
        self.log.debug( "T&E End DB Upgrade");
Example #9
0
    def do_db_upgrade(self):
        # Legacy support hack (supports upgrades from 0.1.6 to 0.1.7)
        if self.db_installed_version == 0:
            bill_date = dbhelper.db_table_exists(self, 'bill_date');
            report_version = dbhelper.db_table_exists(self, 'report_version');
            if bill_date and report_version:
                self.db_installed_version = 1
        # End Legacy support hack


        if self.db_installed_version < 1:
            print "Creating bill_date table"
            sql = """
            CREATE TABLE bill_date (
            time integer,
            set_when integer,
            str_value text
            );
            """
            dbhelper.execute_non_query(self,  sql)


            print "Creating report_version table"
            sql = """
            CREATE TABLE report_version (
            report integer,
            version integer,
            UNIQUE (report, version)
            );
            """
            dbhelper.execute_non_query(self, sql)

        if self.db_installed_version < 4:
            print "Upgrading report_version table to v4"
            sql ="""
            ALTER TABLE report_version ADD COLUMN tags varchar(1024) null;
            """
            dbhelper.execute_non_query(self, sql)

        if self.db_installed_version < 5:
            # In this version we convert to using reportmanager.py
            # The easiest migration path is to remove all the reports!!
            # They will be added back in later but all custom reports will be lost (deleted)
            print "Dropping report_version table"
            sql = "DELETE FROM report " \
                  "WHERE author=%s AND id IN (SELECT report FROM report_version)"
            dbhelper.execute_non_query(self, sql, 'Timing and Estimation Plugin')

            sql = "DROP TABLE report_version"
            dbhelper.execute_non_query(self, sql)

        #version 6 upgraded reports

        # This statement block always goes at the end this method
        dbhelper.set_system_value(self, self.db_version_key, self.db_version)
        self.db_installed_version = self.db_version
Example #10
0
    def do_db_upgrade(self):
        # Legacy support hack (supports upgrades from 0.1.6 to 0.1.7)
        if self.db_installed_version == 0:
            bill_date = dbhelper.db_table_exists(self, 'bill_date')
            report_version = dbhelper.db_table_exists(self, 'report_version')
            if bill_date and report_version:
                self.db_installed_version = 1
        # End Legacy support hack

        if self.db_installed_version < 1:
            print "Creating bill_date table"
            sql = """
            CREATE TABLE bill_date (
            time integer,
            set_when integer,
            str_value text
            );
            """
            dbhelper.execute_non_query(self, sql)

            print "Creating report_version table"
            sql = """
            CREATE TABLE report_version (
            report integer,
            version integer,
            UNIQUE (report, version)
            );
            """
            dbhelper.execute_non_query(self, sql)

        if self.db_installed_version < 4:
            print "Upgrading report_version table to v4"
            sql = """
            ALTER TABLE report_version ADD COLUMN tags varchar(1024) null;
            """
            dbhelper.execute_non_query(self, sql)

        if self.db_installed_version < 5:
            # In this version we convert to using reportmanager.py
            # The easiest migration path is to remove all the reports!!
            # They will be added back in later but all custom reports will be lost (deleted)
            print "Dropping report_version table"
            sql = "DELETE FROM report " \
                  "WHERE author=%s AND id IN (SELECT report FROM report_version)"
            dbhelper.execute_non_query(self, sql,
                                       'Timing and Estimation Plugin')

            sql = "DROP TABLE report_version"
            dbhelper.execute_non_query(self, sql)

        #version 6 upgraded reports

        # This statement block always goes at the end this method
        dbhelper.set_system_value(self, self.db_version_key, self.db_version)
        self.db_installed_version = self.db_version
Example #11
0
    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)
Example #12
0
    def do_db_upgrade(self):
        self.log.debug( "T&E Beginning DB Upgrade");

        #version 6 upgraded reports

        if self.db_installed_version < 7:
            field_settings = "field settings"
            self.config.set( field_settings, "fields", "totalhours, hours, estimatedhours" )
            self.config.set( field_settings, "hours.permission", "TIME_VIEW:remove, TIME_RECORD:disable" )
            self.config.set( field_settings, "estimatedhours.permission", "TIME_RECORD:disable" )

        # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        # This statement block always goes at the end this method
        dbhelper.set_system_value(self.env, self.db_version_key, self.db_version)
        self.db_installed_version = self.db_version
Example #13
0
    def do_db_upgrade(self):
        if self.db_installed_version < 1:
            print "Creating bill_date table"
            sql = """
            CREATE TABLE bill_date (
            time integer,
            set_when integer,
            str_value text
            );
            """
            dbhelper.execute_non_query(self, sql)

        if self.db_installed_version < 5:
            if dbhelper.db_table_exists(self, 'report_version'):
                print "Dropping report_version table"
                sql = "DELETE FROM report " \
                    "WHERE author=%s AND id IN (SELECT report FROM report_version)"
                dbhelper.execute_non_query(self, sql,
                                           'Timing and Estimation Plugin')

                sql = "DROP TABLE report_version"
                dbhelper.execute_non_query(self, sql)

        #version 6 upgraded reports

        if self.db_installed_version < 7:
            field_settings = "field settings"
            self.config.set(
                field_settings, "fields",
                "billable, totalhours, hours, estimatedhours, internal")
            self.config.set(field_settings, "billable.permission",
                            "TIME_VIEW:hide, TIME_RECORD:disable")
            self.config.set(field_settings, "hours.permission",
                            "TIME_VIEW:remove, TIME_RECORD:disable")
            self.config.set(field_settings, "estimatedhours.permission",
                            "TIME_RECORD:disable")
            self.config.set(field_settings, "internal.permission",
                            "TIME_RECORD:hide")

        # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        # This statement block always goes at the end this method
        dbhelper.set_system_value(self, self.db_version_key, self.db_version)
        self.db_installed_version = self.db_version
Example #14
0
    def do_db_upgrade(self):
        self.log.debug( "T&E Beginning DB Upgrade");
        if self.db_installed_version < 1:
            if not dbhelper.db_table_exists(self.env, 'bill_date'):
                print "Creating bill_date table"
                sql = """
                CREATE TABLE bill_date (
                time integer,
                set_when integer,
                str_value text
                );"""
                dbhelper.execute_non_query(self.env,  sql)


        if self.db_installed_version < 5:
            if dbhelper.db_table_exists(self.env, 'report_version'):
                print "Dropping report_version table"
                sql = "DELETE FROM report " \
                    "WHERE author=%s AND id IN (SELECT report FROM report_version)"
                dbhelper.execute_non_query(self.env, sql, 'Timing and Estimation Plugin')

                sql = "DROP TABLE report_version"
                dbhelper.execute_non_query(self.env, sql)

        #version 6 upgraded reports


        if self.db_installed_version < 7:
            field_settings = "field settings"
            self.config.set( field_settings, "fields", "billable, totalhours, hours, estimatedhours, internal" )
            self.config.set( field_settings, "billable.permission", "TIME_VIEW:hide, TIME_RECORD:disable" )
            self.config.set( field_settings, "hours.permission", "TIME_VIEW:remove, TIME_RECORD:disable" )
            self.config.set( field_settings, "estimatedhours.permission", "TIME_RECORD:disable" )
            self.config.set( field_settings, "internal.permission", "TIME_RECORD:hide")

        # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        # This statement block always goes at the end this method
        dbhelper.set_system_value(self.env, self.db_version_key, self.db_version)
        self.db_installed_version = self.db_version