# coding=utf8
"""
-Debian Archive Kit Database Update Script
-Copyright © 2008 Michael Casadevall <mcasadevall@debian.org>
-Copyright © 2009 Mike O'Connor <stew@debian.org>
+Add constraints to src_uploaders
-Debian Archive Kit Database Update Script 8
+@contact: Debian FTP Master <ftpmaster@debian.org>
+@copyright: 2009 Mark Hymers <mhy@debian.org>
+@license: GNU General Public License version 2 or later
"""
# This program is free software; you can redistribute it and/or modify
################################################################################
+# <mhy> oh no, Ganneff has just corrected my english
################################################################################
################################################################################
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)))