From: Joerg Jaspert Date: Sat, 14 Mar 2009 11:37:46 +0000 (+0100) Subject: config -> database X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9ab9e101a215be6125f0f2ccb73d346de4571014;p=dak config -> database move more values of suite into database Signed-off-by: Joerg Jaspert --- diff --git a/dak/dakdb/update8.py b/dak/dakdb/update8.py new file mode 100755 index 00000000..fc505f7a --- /dev/null +++ b/dak/dakdb/update8.py @@ -0,0 +1,103 @@ +#!/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 8 +""" + +# 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 more of the suite config into the DB" + Cnf = get_conf() + + try: + c = self.db.cursor() + + c.execute("ALTER TABLE suite ADD COLUMN copychanges TEXT;") + query = "UPDATE suite SET copychanges = %s WHERE suite_name = %s" #: Update query + for suite in Cnf.SubTree("Suite").List(): + copychanges = Cnf.Find("Suite::%s::CopyChanges" % (suite)) + print "[CopyChanges] Processing suite %s" % (suite) + if not copychanges: + continue + suite = suite.lower() + c.execute(query, [copychanges, suite]) + + c.execute("ALTER TABLE suite ADD COLUMN copydotdak TEXT;") + query = "UPDATE suite SET copydotdak = %s WHERE suite_name = %s" #: Update query + for suite in Cnf.SubTree("Suite").List(): + copydotdak = Cnf.Find("Suite::%s::CopyDotDak" % (suite)) + print "[CopyDotDak] Processing suite %s" % (suite) + if not copydotdak: + continue + suite = suite.lower() + c.execute(query, [copydotdak, suite]) + + c.execute("ALTER TABLE suite ADD COLUMN commentsdir TEXT;") + query = "UPDATE suite SET commentsdir = %s WHERE suite_name = %s" #: Update query + for suite in Cnf.SubTree("Suite").List(): + commentsdir = Cnf.Find("Suite::%s::CommentsDir" % (suite)) + print "[CommentsDir] Processing suite %s" % (suite) + if not commentsdir: + continue + suite = suite.lower() + c.execute(query, [commentsdir, suite]) + + c.execute("ALTER TABLE suite ADD COLUMN overridesuite TEXT;") + query = "UPDATE suite SET overridesuite = %s WHERE suite_name = %s" #: Update query + for suite in Cnf.SubTree("Suite").List(): + overridesuite = Cnf.Find("Suite::%s::OverrideSuite" % (suite)) + print "[OverrideSuite] Processing suite %s" % (suite) + if not overridesuite: + continue + suite = suite.lower() + c.execute(query, [overridesuite, suite]) + + c.execute("ALTER TABLE suite ADD COLUMN changelogbase TEXT;") + query = "UPDATE suite SET changelogbase = %s WHERE suite_name = %s" #: Update query + for suite in Cnf.SubTree("Suite").List(): + changelogbase = Cnf.Find("Suite::%s::ChangeLogBase" % (suite)) + print "[ChangeLogBase] Processing suite %s" % (suite) + if not changelogbase: + continue + suite = suite.lower() + c.execute(query, [changelogbase, suite]) + + c.execute("UPDATE config SET value = '8' WHERE name = 'db_revision'") + self.db.commit() + + except psycopg2.ProgrammingError, msg: + self.db.rollback() + raise DBUpdateError, "Unable to apply suite config updates, rollback issued. Error message : %s" % (str(msg)) diff --git a/dak/update_db.py b/dak/update_db.py index 0df3b946..b596f2fc 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 = 7 +required_database_schema = 8 ################################################################################