Package buildbot :: Package db :: Package schema :: Module v5
[frames] | no frames]

Source Code for Module buildbot.db.schema.v5

 1  # This file is part of Buildbot.  Buildbot is free software: you can 
 2  # redistribute it and/or modify it under the terms of the GNU General Public 
 3  # License as published by the Free Software Foundation, version 2. 
 4  # 
 5  # This program is distributed in the hope that it will be useful, but WITHOUT 
 6  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 7  # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
 8  # details. 
 9  # 
10  # You should have received a copy of the GNU General Public License along with 
11  # this program; if not, write to the Free Software Foundation, Inc., 51 
12  # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
13  # 
14  # Copyright Buildbot Team Members 
15   
16  from buildbot.db.schema import base 
17   
18 -class Upgrader(base.Upgrader):
19 - def upgrade(self):
20 self.add_index("buildrequests", "buildsetid") 21 self.add_index("buildrequests", "buildername", 255) 22 self.add_index("buildrequests", "complete") 23 self.add_index("buildrequests", "claimed_at") 24 self.add_index("buildrequests", "claimed_by_name", 255) 25 26 self.add_index("builds", "number") 27 self.add_index("builds", "brid") 28 29 self.add_index("buildsets", "complete") 30 self.add_index("buildsets", "submitted_at") 31 32 self.add_index("buildset_properties", "buildsetid") 33 34 self.add_index("changes", "branch", 255) 35 self.add_index("changes", "revision", 255) 36 self.add_index("changes", "author", 255) 37 self.add_index("changes", "category", 255) 38 self.add_index("changes", "when_timestamp") 39 40 self.add_index("change_files", "changeid") 41 self.add_index("change_links", "changeid") 42 self.add_index("change_properties", "changeid") 43 44 # schedulers already has an index 45 46 self.add_index("scheduler_changes", "schedulerid") 47 self.add_index("scheduler_changes", "changeid") 48 49 self.add_index("scheduler_upstream_buildsets", "buildsetid") 50 self.add_index("scheduler_upstream_buildsets", "schedulerid") 51 self.add_index("scheduler_upstream_buildsets", "active") 52 53 # sourcestamps are only queried by id, no need for additional indexes 54 55 self.add_index("sourcestamp_changes", "sourcestampid") 56 57 self.set_version()
58
59 - def add_index(self, table, column, length=None):
60 lengthstr="" 61 if length is not None and self.dbapiName == 'MySQLdb': 62 lengthstr = " (%i)" % length 63 q = "CREATE INDEX `%(table)s_%(column)s` ON `%(table)s` (`%(column)s`%(lengthstr)s)" 64 cursor = self.conn.cursor() 65 cursor.execute(q % {'table': table, 'column': column, 'lengthstr': lengthstr})
66
67 - def set_version(self):
68 c = self.conn.cursor() 69 c.execute("""UPDATE version set version = 5 where version = 4""")
70