Ejemplo n.º 1
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");
Ejemplo n.º 2
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");
Ejemplo n.º 3
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
Ejemplo n.º 4
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
    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")
Ejemplo n.º 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:
            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