From 49fcac925742306c7135f021723ed905e6027dff Mon Sep 17 00:00:00 2001 From: Joerg Jaspert Date: Fri, 13 Mar 2009 22:40:39 +0100 Subject: [PATCH] update7 add an update script to move more stuff into the database. Signed-off-by: Joerg Jaspert --- dak/dakdb/update7.py | 119 +++++++++++++++++++++++++++++++++++++++++++ dak/update_db.py | 2 +- docs/README.quotes | 5 -- 3 files changed, 120 insertions(+), 6 deletions(-) create mode 100755 dak/dakdb/update7.py diff --git a/dak/dakdb/update7.py b/dak/dakdb/update7.py new file mode 100755 index 00000000..96a36146 --- /dev/null +++ b/dak/dakdb/update7.py @@ -0,0 +1,119 @@ +#!/usr/bin/env python +# coding=utf8 + +""" +Debian Archive Kit Database Update Script +Copyright © 2008 Michael Casadevall +Copyright © 2009 Joerg Jaspert + +Debian Archive Kit Database Update Script 7 +""" + +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +################################################################################ + +# * Ganneff ponders how to best write the text to -devel. (need to tell em in +# case they find more bugs). "We fixed the fucking idiotic broken implementation +# to be less so" is probably not the nicest, even if perfect valid, way to say so + +################################################################################ + +import psycopg2 +import time +from daklib.dak_exceptions import DBUpdateError +from daklib.utils import get_conf + +################################################################################ + +def do_update(self): + print "Moving some of the suite config into the DB" + Cnf = get_conf() + + try: + c = self.db.cursor() + + c.execute("ALTER TABLE suite ADD COLUMN untouchable BOOLEAN NOT NULL DEFAULT FALSE;") + query = "UPDATE suite SET untouchable = TRUE WHERE suite_name = %s" #: Update query + for suite in Cnf.SubTree("Suite").List(): + untouchable = Cnf.Find("Suite::%s::Announce" % (suite)) + if not untouchable: + continue + print "[Untouchable] Processing suite %s" % (suite) + suite = suite.lower() + c.execute(query, [suite]) + + + c.execute("ALTER TABLE suite ADD COLUMN announce text DEFAULT NOT NULL 'debian-devel-changes@lists.debian.org';") + query = "UPDATE suite SET announce = %s WHERE suite_name = %s" #: Update query + for suite in Cnf.SubTree("Suite").List(): + announce_list = Cnf.Find("Suite::%s::Announce" % (suite)) + print "[Announce] Processing suite %s" % (suite) + suite = suite.lower() + c.execute(query, [announce_list, suite]) + + c.execute("ALTER TABLE suite ADD COLUMN codename text;") + query = "UPDATE suite SET codename = %s WHERE suite_name = %s" #: Update query + for suite in Cnf.SubTree("Suite").List(): + codename = Cnf.Find("Suite::%s::CodeName" % (suite)) + print "[Codename] Processing suite %s" % (suite) + suite = suite.lower() + c.execute(query, [codename, suite]) + + c.execute("ALTER TABLE suite ADD COLUMN overridecodename text;") + query = "UPDATE suite SET overridecodename = %s WHERE suite_name = %s" #: Update query + for suite in Cnf.SubTree("Suite").List(): + codename = Cnf.Find("Suite::%s::OverrideCodeName" % (suite)) + print "[OverrideCodeName] Processing suite %s" % (suite) + suite = suite.lower() + c.execute(query, [codename, suite]) + + c.execute("ALTER TABLE suite ADD COLUMN validtime integer NOT NULL DEFAULT 604800;") + query = "UPDATE suite SET validtime = %s WHERE suite_name = %s" #: Update query + for suite in Cnf.SubTree("Suite").List(): + validtime = Cnf.Find("Suite::%s::ValidTime" % (suite)) + print "[ValidTime] Processing suite %s" % (suite) + if not validtime: + validtime = 0 + suite = suite.lower() + c.execute(query, [validtime, suite]) + + c.execute("ALTER TABLE suite ADD COLUMN priority integer NOT NULL DEFAULT 0;") + query = "UPDATE suite SET priority = %s WHERE suite_name = %s" #: Update query + for suite in Cnf.SubTree("Suite").List(): + priority = Cnf.Find("Suite::%s::Priority" % (suite)) + print "[Priority] Processing suite %s" % (suite) + if not priority: + priority = 0 + suite = suite.lower() + c.execute(query, [priority, suite]) + + + c.execute("ALTER TABLE suite ADD COLUMN notautomatic BOOLEAN NOT NULL DEFAULT FALSE;") + query = "UPDATE suite SET notautomatic = TRUE WHERE suite_name = %s" #: Update query + for suite in Cnf.SubTree("Suite").List(): + notautomatic = Cnf.Find("Suite::%s::NotAutomatic" % (suite)) + print "[NotAutomatic] Processing suite %s" % (suite) + if not notautomatic: + continue + suite = suite.lower() + c.execute(query, [suite]) + + c.execute("UPDATE config SET value = '7' WHERE name = 'db_revision'") + self.db.commit() + + except psycopg2.ProgrammingError, msg: + self.db.rollback() + raise DBUpdateError, "Unable to appy suite config updates, rollback issued. Error message : %s" % (str(msg)) diff --git a/dak/update_db.py b/dak/update_db.py index 378dacf0..0df3b946 100755 --- a/dak/update_db.py +++ b/dak/update_db.py @@ -45,7 +45,7 @@ from daklib.dak_exceptions import DBUpdateError Cnf = None projectB = None -required_database_schema = 6 +required_database_schema = 7 ################################################################################ diff --git a/docs/README.quotes b/docs/README.quotes index c696fbeb..a71c89db 100644 --- a/docs/README.quotes +++ b/docs/README.quotes @@ -345,8 +345,3 @@ Canadians: This is a lighthouse. Your call. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -* Ganneff ponders how to best write the text to -devel. (need to tell em in - case they find more bugs). "We fixed the fucking idiotic broken implementation - to be less so" is probably not the nicest, even if perfect valid, way to say so - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- 2.39.2