1 from twisted.python import reflect
2
3
4
5 CURRENT_VERSION = 6
6
8 """
9 This class is responsible for managing the database schema and upgrading it
10 as necessary. This includes both the *actual* database and the old pickle
11 database, as migrations move data between the two.
12
13 Note that this class is *entirely synchronous*! Performing any other operations
14 while changing the schema is just asking for trouble.
15 """
20
22 """
23 Get the current schema version for this database
24 """
25 close_conn = False
26 if not conn:
27 conn = self.spec.get_sync_connection()
28 close_conn = True
29 c = conn.cursor()
30 try:
31 try:
32 c.execute("SELECT version FROM version")
33 rows = c.fetchall()
34 assert len(rows) == 1, "%i rows in version table! (should only be 1)" % len(rows)
35 return rows[0][0]
36 except (self.dbapi.OperationalError, self.dbapi.ProgrammingError):
37
38 return 0
39 finally:
40 if close_conn:
41 conn.close()
42
44 """
45 Get the current db version for this release of buildbot
46 """
47 return CURRENT_VERSION
48
54
70