Package dak :: Package dakdb :: Module update126
[hide private]
[frames] | no frames]

Source Code for Module dak.dakdb.update126

 1  """add per-suite ACL table 
 2   
 3  @contact: Debian FTP Master <ftpmaster@debian.org> 
 4  @copyright: 2023 Emilio Pozuelo Monfort <pochu@debian.org> 
 5  @license: GNU General Public License version 2 or later 
 6  """ 
 7   
 8  # This program is free software; you can redistribute it and/or modify 
 9  # it under the terms of the GNU General Public License as published by 
10  # the Free Software Foundation; either version 2 of the License, or 
11  # (at your option) any later version. 
12   
13  # This program is distributed in the hope that it will be useful, 
14  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
15  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
16  # GNU General Public License for more details. 
17   
18  # You should have received a copy of the GNU General Public License 
19  # along with this program; if not, write to the Free Software 
20  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
21   
22  ################################################################################ 
23   
24  import psycopg2 
25  from daklib.dak_exceptions import DBUpdateError 
26  from daklib.config import Config 
27   
28  statements = [ 
29  """ 
30  CREATE TABLE acl_per_suite ( 
31      acl_id INTEGER NOT NULL REFERENCES acl(id) ON DELETE CASCADE, 
32      fingerprint_id INTEGER NOT NULL REFERENCES fingerprint(id) ON DELETE CASCADE, 
33      suite_id INTEGER NOT NULL REFERENCES suite(id) ON DELETE CASCADE, 
34      reason TEXT, 
35      created_by_id INTEGER REFERENCES fingerprint(id), 
36      created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, 
37      PRIMARY KEY (acl_id, fingerprint_id, suite_id) 
38  ) 
39  """ 
40  ] 
41   
42  ################################################################################ 
43   
44   
45 -def do_update(self):
46 print(__doc__) 47 try: 48 cnf = Config() 49 50 c = self.db.cursor() 51 52 for stmt in statements: 53 c.execute(stmt) 54 55 c.execute("UPDATE config SET value = '126' WHERE name = 'db_revision'") 56 self.db.commit() 57 58 except psycopg2.ProgrammingError as msg: 59 self.db.rollback() 60 raise DBUpdateError('Unable to apply sick update 126, rollback issued. Error message: {0}'.format(msg))
61