]> git.decadent.org.uk Git - dak.git/blob - dak/dakdb/update9.py
Convert exception handling to Python3 syntax.
[dak.git] / dak / dakdb / update9.py
1 #!/usr/bin/env python
2 # coding=utf8
3
4 """
5 Pending contents disinguished by arch
6
7 @contact: Debian FTP Master <ftpmaster@debian.org>
8 @copyright: 2008  Michael Casadevall <mcasadevall@debian.org>
9 @copyright: 2009  Mike O'Connor <stew@debian.org>
10 @license: GNU General Public License version 2 or later
11 """
12
13 # This program is free software; you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation; either version 2 of the License, or
16 # (at your option) any later version.
17
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 # GNU General Public License for more details.
22
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write to the Free Software
25 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
27 ################################################################################
28
29 # * Ganneff ponders how to best write the text to -devel. (need to tell em in
30 #   case they find more bugs). "We fixed the fucking idiotic broken implementation
31 #   to be less so" is probably not the nicest, even if perfect valid, way to say so
32
33 ################################################################################
34
35 import psycopg2
36 import time
37 from daklib.dak_exceptions import DBUpdateError
38 from daklib.utils import get_conf
39
40 ################################################################################
41
42 def do_update(self):
43     print "pending_contents should distinguish by arch"
44     Cnf = get_conf()
45
46     try:
47         c = self.db.cursor()
48
49         c.execute("DELETE FROM pending_content_associations")
50         c.execute("""ALTER TABLE pending_content_associations
51                          ADD COLUMN architecture integer NOT NULL""")
52         c.execute("""ALTER TABLE ONLY pending_content_associations
53                          ADD CONSTRAINT pending_content_assiciations_arch
54                          FOREIGN KEY (architecture)
55                          REFERENCES architecture(id)
56                          ON DELETE CASCADE""")
57         c.execute("UPDATE config SET value = '9' WHERE name = 'db_revision'")
58         self.db.commit()
59
60     except psycopg2.ProgrammingError as msg:
61         self.db.rollback()
62         raise DBUpdateError, "Unable to apply suite config updates, rollback issued. Error message : %s" % (str(msg))