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

Source Code for Module buildbot.db.schema.v2

 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   
17  from buildbot.db.schema import base 
18   
19 -class Upgrader(base.Upgrader):
20 - def upgrade(self):
21 self.add_columns() 22 self.set_version()
23
24 - def add_columns(self):
25 if self.dbapiName == 'MySQLdb': 26 default_text = "" 27 else: 28 default_text = "default ''" 29 30 cursor = self.conn.cursor() 31 cursor.execute(""" 32 ALTER TABLE changes 33 add column `repository` text not null %s 34 """ % default_text) 35 cursor.execute(""" 36 ALTER TABLE changes 37 add column `project` text not null %s 38 """ % default_text) 39 cursor.execute(""" 40 ALTER TABLE sourcestamps 41 add column `repository` text not null %s 42 """ % default_text) 43 cursor.execute(""" 44 ALTER TABLE sourcestamps 45 add column `project` text not null %s 46 """ % default_text)
47
48 - def set_version(self):
49 c = self.conn.cursor() 50 c.execute("""UPDATE version set version = 2 where version = 1""")
51