X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fdakdb%2Fupdate10.py;h=31c70d379206504bf48b56ef7570f2137bb1bbfe;hb=e2c4fd7f21c3b33cd7192bded5d6373e0ee90374;hp=cf1caa1c93876de7f8874dc327f78c3046bb2a74;hpb=a17cc80b937bb8ab8cc0a92849fefd33f436e8f8;p=dak.git diff --git a/dak/dakdb/update10.py b/dak/dakdb/update10.py old mode 100644 new mode 100755 index cf1caa1c..31c70d37 --- a/dak/dakdb/update10.py +++ b/dak/dakdb/update10.py @@ -2,11 +2,11 @@ # coding=utf8 """ -Debian Archive Kit Database Update Script -Copyright © 2008 Michael Casadevall -Copyright © 2009 Mike O'Connor +Add constraints to src_uploaders -Debian Archive Kit Database Update Script 8 +@contact: Debian FTP Master +@copyright: 2009 Mark Hymers +@license: GNU General Public License version 2 or later """ # This program is free software; you can redistribute it and/or modify @@ -25,6 +25,7 @@ Debian Archive Kit Database Update Script 8 ################################################################################ +# oh no, Ganneff has just corrected my english ################################################################################ @@ -36,21 +37,20 @@ from daklib.utils import get_conf ################################################################################ def do_update(self): - print "add package_type enum" + print "Add constraints to src_uploaders" Cnf = get_conf() try: c = self.db.cursor() - - c.execute("CREATE TYPE package_type AS ENUM('deb','udeb','tdeb', 'dsc')") - c.execute("ALTER TABLE binaries RENAME COLUMN type to type_text" ); - c.execute("ALTER TABLE binaries ADD COLUMN type package_type" ); - c.execute("UPDATE binaries set type=type_text::package_type" ); - c.execute("ALTER TABLE binaries DROP COLUMN type_text" ); - c.execute("CREATE INDEX binary_type_ids on binaries(type)") - + # Deal with out-of-date src_uploaders entries + c.execute("DELETE FROM src_uploaders WHERE source NOT IN (SELECT id FROM source)") + c.execute("DELETE FROM src_uploaders WHERE maintainer NOT IN (SELECT id FROM maintainer)") + # Add constraints + c.execute("ALTER TABLE src_uploaders ADD CONSTRAINT src_uploaders_maintainer FOREIGN KEY (maintainer) REFERENCES maintainer(id) ON DELETE CASCADE") + c.execute("ALTER TABLE src_uploaders ADD CONSTRAINT src_uploaders_source FOREIGN KEY (source) REFERENCES source(id) ON DELETE CASCADE") + c.execute("UPDATE config SET value = '10' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, "Unable to apply binary type enum update, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to apply suite config updates, rollback issued. Error message : %s" % (str(msg)))