コード例 #1
0
ファイル: api.py プロジェクト: pombredanne/trachacks
    def db_do_upgrade(self):
        print "Beginning DB Upgrade"
        tables = dbhelper.get_database_table_names(self.env.get_db_cnx())
        bill_date = [table for table in tables if table == 'bill_date']
        report_version = [
            table for table in tables if table == 'report_version'
        ]

        if not 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.get_db_cnx(), sql)
        if not report_version:
            print "Creating report_version table"
            sql = """
            CREATE TABLE report_version (
            report integer,
            version integer,
            UNIQUE (report, version)
            );
            """
            dbhelper.execute_non_query(self.env.get_db_cnx(), sql)
コード例 #2
0
ファイル: api.py プロジェクト: nyuhuhuu/trachacks
    def db_do_upgrade(self):
        print "Beginning DB Upgrade"
        tables = dbhelper.get_database_table_names(self.env.get_db_cnx())
        bill_date = [table for table in tables if table == 'bill_date']
        report_version = [table for table in tables if table == 'report_version']

        if not 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.get_db_cnx(), sql)
        if not report_version:
            print "Creating report_version table"
            sql = """
            CREATE TABLE report_version (
            report integer,
            version integer,
            UNIQUE (report, version)
            );
            """
            dbhelper.execute_non_query(self.env.get_db_cnx(), sql)
コード例 #3
0
ファイル: api.py プロジェクト: nyuhuhuu/trachacks
 def db_needs_upgrade(self):
     tables = dbhelper.get_database_table_names(self.env.get_db_cnx())
     bill_date = [table for table in tables if table == 'bill_date']
     report_version = [table for table in tables if table == 'report_version']
     if bill_date and report_version:
         return False;
     return True;
コード例 #4
0
ファイル: api.py プロジェクト: pombredanne/trachacks
 def db_needs_upgrade(self):
     tables = dbhelper.get_database_table_names(self.env.get_db_cnx())
     bill_date = [table for table in tables if table == 'bill_date']
     report_version = [
         table for table in tables if table == 'report_version'
     ]
     if bill_date and report_version:
         return False
     return True
コード例 #5
0
ファイル: api.py プロジェクト: pombredanne/trachacks
    def reports_need_upgrade(self):
        bit = False
        tables = dbhelper.get_database_table_names(self.env.get_db_cnx())
        report_version = [
            table for table in tables if table == 'report_version'
        ]
        if not report_version:
            return True

        #make versions hash
        _versions = dbhelper.get_result_set(
            self.env.get_db_cnx(), """
                                           SELECT report as id, version, r.title as title
                                           FROM report_version
                                           JOIN report r ON r.Id = report_version.report
                                           """)
        versions = {}
        for (id, version, title) in _versions.rows:
            versions[title] = (id, version)

        for report_group in all_reports:
            rlist = report_group["reports"]
            for report in rlist:
                title = report["title"]
                new_version = report["version"]
                #the report map is a list of (id, name) tuples for the reports
                # here we want to see if our report is in the list
                idx = [
                    i for i in range(0, len(self.reportmap))
                    if self.reportmap[i][1] == title
                ]
                if not idx:
                    self.log.warning("Report '%s' needs to be added" % title)
                    bit = True
                else:
                    # If we had a report make sure its at the correct version
                    if versions.has_key(title):
                        (id, ver) = versions[title]
                    else:
                        ver = 0
                    if ver < new_version:
                        bit = True
        return bit
コード例 #6
0
ファイル: api.py プロジェクト: nyuhuhuu/trachacks
 def reports_need_upgrade(self):
     bit = False
     tables = dbhelper.get_database_table_names(self.env.get_db_cnx())
     report_version = [table for table in tables if table == 'report_version']
     if not report_version:
         return True
     
     #make versions hash        
     _versions = dbhelper.get_result_set(self.env.get_db_cnx(),
                                        """
                                        SELECT report as id, version, r.title as title
                                        FROM report_version
                                        JOIN report r ON r.Id = report_version.report
                                        """)
     versions = {}
     for (id, version, title) in _versions.rows:
         versions[title] = (id, version)
     
         
     for report_group in all_reports:
         rlist = report_group["reports"]
         for report in rlist:
             title = report["title"]
             new_version = report["version"]
             #the report map is a list of (id, name) tuples for the reports
             # here we want to see if our report is in the list
             idx = [i for i in range(0, len(self.reportmap)) if self.reportmap[i][1] == title]
             if not idx:
                 self.log.warning("Report '%s' needs to be added" % title)
                 bit = True;
             else:
                 # If we had a report make sure its at the correct version
                 if versions.has_key(title):
                     (id, ver) = versions[title]
                 else:
                     ver = 0
                 if ver < new_version:
                     bit = True
     return bit