[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[dak/master] config -> database



move more values of suite into database

Signed-off-by: Joerg Jaspert <joerg@debian.org>
---
 dak/dakdb/update8.py |  103 ++++++++++++++++++++++++++++++++++++++++++++++++++
 dak/update_db.py     |    2 +-
 2 files changed, 104 insertions(+), 1 deletions(-)
 create mode 100755 dak/dakdb/update8.py

diff --git a/dak/dakdb/update8.py b/dak/dakdb/update8.py
new file mode 100755
index 0000000..fc505f7
--- /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 <mcasadevall@debian.org>
+Copyright © 2009  Joerg Jaspert <joerg@debian.org>
+
+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 0df3b94..b596f2f 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
 
 ################################################################################
 
-- 
1.5.6.5


Reply to: