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

Source Code for Module buildbot.db.schema.v5

 1  from buildbot.db.schema import base 
 2  from buildbot.db.exceptions import DatabaseNotReadyError 
 3   
4 -class Upgrader(base.Upgrader):
5 - def upgrade(self):
6 self.add_index("buildrequests", "buildsetid") 7 self.add_index("buildrequests", "buildername", 255) 8 self.add_index("buildrequests", "complete") 9 self.add_index("buildrequests", "claimed_at") 10 self.add_index("buildrequests", "claimed_by_name", 255) 11 12 self.add_index("builds", "number") 13 self.add_index("builds", "brid") 14 15 self.add_index("buildsets", "complete") 16 self.add_index("buildsets", "submitted_at") 17 18 self.add_index("buildset_properties", "buildsetid") 19 20 self.add_index("changes", "branch", 255) 21 self.add_index("changes", "revision", 255) 22 self.add_index("changes", "author", 255) 23 self.add_index("changes", "category", 255) 24 self.add_index("changes", "when_timestamp") 25 26 self.add_index("change_files", "changeid") 27 self.add_index("change_links", "changeid") 28 self.add_index("change_properties", "changeid") 29 30 # schedulers already has an index 31 32 self.add_index("scheduler_changes", "schedulerid") 33 self.add_index("scheduler_changes", "changeid") 34 35 self.add_index("scheduler_upstream_buildsets", "buildsetid") 36 self.add_index("scheduler_upstream_buildsets", "schedulerid") 37 self.add_index("scheduler_upstream_buildsets", "active") 38 39 # sourcestamps are only queried by id, no need for additional indexes 40 41 self.add_index("sourcestamp_changes", "sourcestampid") 42 43 self.set_version()
44
45 - def add_index(self, table, column, length=None):
46 lengthstr="" 47 if length is not None and self.dbapiName == 'MySQLdb': 48 lengthstr = " (%i)" % length 49 q = "CREATE INDEX `%(table)s_%(column)s` ON `%(table)s` (`%(column)s`%(lengthstr)s)" 50 cursor = self.conn.cursor() 51 cursor.execute(q % locals())
52
53 - def set_version(self):
54 c = self.conn.cursor() 55 c.execute("""UPDATE version set version = 5 where version = 4""")
56