1 from buildbot.db.schema import base
2
7
9 cursor = self.conn.cursor()
10
11 cursor.execute("""
12 ALTER TABLE schedulers
13 RENAME TO schedulers_old
14 """)
15
16 try:
17 cursor.execute("""
18 CREATE TABLE schedulers (
19 `schedulerid` INTEGER PRIMARY KEY, -- joins to other tables
20 `name` VARCHAR(127) NOT NULL, -- the scheduler's name according to master.cfg
21 `class_name` VARCHAR(127) NOT NULL, -- the scheduler's class
22 `state` VARCHAR(1024) NOT NULL -- JSON-encoded state dictionary
23 );
24 """)
25 except:
26
27 cursor.execute("""
28 ALTER TABLE schedulers_old
29 RENAME TO schedulers
30 """)
31 raise
32
33 try:
34 cursor.execute("""
35 CREATE UNIQUE INDEX `name_and_class` ON
36 schedulers (`name`, `class_name`)
37 """)
38
39 cursor.execute("""
40 INSERT INTO schedulers (`schedulerid`, `name`, `state`, `class_name`)
41 SELECT `schedulerid`, `name`, `state`, '' FROM schedulers_old
42 """)
43 cursor.execute("""
44 DROP TABLE schedulers_old
45 """)
46 except:
47
48 cursor.execute("""
49 DROP TABLE schedulers
50 """)
51 cursor.execute("""
52 ALTER TABLE schedulers_old
53 RENAME TO schedulers
54 """)
55 raise
56
58 c = self.conn.cursor()
59 c.execute("""UPDATE version set version = 3 where version = 2""")
60