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