X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fdakdb%2Fupdate2.py;h=2e3cb446b55f1cedb985628f17524caa1520964b;hb=1e1457bde3318c6605b4c97d4299803fdaf8e774;hp=bddf0a70f54fdf3a15659b4500ea2d207b232eb8;hpb=56ba4e23bb2f2acb83f18ff697cf0907256a489d;p=dak.git diff --git a/dak/dakdb/update2.py b/dak/dakdb/update2.py old mode 100644 new mode 100755 index bddf0a70..2e3cb446 --- a/dak/dakdb/update2.py +++ b/dak/dakdb/update2.py @@ -1,9 +1,14 @@ #!/usr/bin/env python # coding=utf8 -# Debian Archive Kit Database Update Script -# Copyright © 2008 Michael Casadevall -# Copyright © 2008 Roger Leigh +""" +debversion + +@contact: Debian FTP Master +@copyright: 2008 Michael Casadevall +@copyright: 2008 Roger Leigh +@license: GNU General Public License version 2 or later +""" # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,17 +26,26 @@ ################################################################################ -import psycopg2, time +import psycopg2 +import time +from daklib.dak_exceptions import DBUpdateError ################################################################################ def do_update(self): - print "Note the PL/Perl (plperl) procedural language must be enabled first." - print "Run 'createlang plpgsql projectb' to add it." + print "Note: to be able to enable the the PL/Perl (plperl) procedural language, we do" + print "need postgresql-plperl-$postgres-version installed. Make sure that this is the" + print "case before you continue. Interrupt if it isn't, sleeping 5 seconds now." + print "(We need to be database superuser for this to work!)" + time.sleep (5) try: c = self.db.cursor() + print "Enabling PL/Perl language" + c.execute("CREATE LANGUAGE plperl;") + c.execute("CREATE LANGUAGE plpgsql;") + print "Adding debversion type to database." # Not present in all databases, maybe PL/Perl version-dependent? @@ -378,12 +392,10 @@ $$ c.execute("ALTER TABLE source ALTER COLUMN version TYPE debversion;") c.execute("ALTER TABLE binaries ALTER COLUMN version TYPE debversion;") - c.execute("UPDATE config SET value = '1' WHERE name = 'db_revision'") + c.execute("UPDATE config SET value = '2' WHERE name = 'db_revision'") self.db.commit() except psycopg2.ProgrammingError, msg: self.db.rollback() - print "FATAL: Unable to apply debversion table update 2!" - print "Error Message: " + str(msg) - print "Database changes have been rolled back." + raise DBUpdateError, "Unable to appy debversion updates, rollback issued. Error message : %s" % (str(msg))