]> git.decadent.org.uk Git - dak.git/commitdiff
Merge remote branch 'drkranz/master' into merge
authorJoerg Jaspert <joerg@debian.org>
Tue, 24 Nov 2009 22:57:14 +0000 (23:57 +0100)
committerJoerg Jaspert <joerg@debian.org>
Tue, 24 Nov 2009 22:57:14 +0000 (23:57 +0100)
* drkranz/master:
  Handle broken pipe while waiting for action

Signed-off-by: Joerg Jaspert <joerg@debian.org>
dak/dakdb/update26.py [new file with mode: 0755]
dak/override.py
dak/update_db.py

diff --git a/dak/dakdb/update26.py b/dak/dakdb/update26.py
new file mode 100755 (executable)
index 0000000..1b9a7fc
--- /dev/null
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+
+"""
+Add created,modified columns for all tables.
+
+@contact: Debian FTP Master <ftpmaster@debian.org>
+@copyright: 2009  Barry deFreese <bdefreese@debian.org>
+@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
+# 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
+
+import psycopg2
+
+def do_update(self):
+    print "Add created, modified fields for all tables."
+
+    updatetables = ['architecture', 'archive', 'bin_associations', 'bin_contents',
+        'binaries', 'binary_acl', 'binary_acl_map', 'build_queue', 'build_queue_files',
+        'changes', 'changes_pending_binaries', 'changes_pending_files',
+        'changes_pending_files_map', 'changes_pending_source', 'changes_pending_source_files',
+        'changes_pool_files', 'component', 'config', 'dsc_files', 'files', 'fingerprint',
+        'keyring_acl_map', 'keyrings', 'location', 'maintainer', 'new_comments', 'override',
+        'override_type', 'policy_queue', 'priority', 'section', 'source', 'source_acl',
+        'src_associations', 'src_format', 'src_uploaders', 'suite', 'suite_architectures',
+        'suite_build_queue_copy', 'suite_src_formats', 'uid', 'upload_blocks']
+
+    c = self.db.cursor()
+
+    print "Create trigger function."
+    c.execute("""CREATE OR REPLACE FUNCTION tfunc_set_modified() RETURNS trigger AS $$
+    BEGIN NEW.modified = now(); return NEW; END;
+    $$ LANGUAGE 'plpgsql'""")
+
+    try:
+        for updatetable in updatetables:
+
+            print "Add created field to %s." % updatetable
+            c.execute("ALTER TABLE %s ADD COLUMN created TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now()" % updatetable)
+
+            print "Add modified field to %s." % updatetable
+            c.execute("ALTER TABLE %s ADD COLUMN modified TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now()" % updatetable)
+
+            print "Create modified trigger."
+            c.execute("""CREATE TRIGGER modified_%s BEFORE UPDATE ON %s
+            FOR EACH ROW EXECUTE PROCEDURE tfunc_set_modified()""" % (updatetable, updatetable))
+
+        print "Committing"
+        c.execute("UPDATE config SET value = '26' WHERE name = 'db_revision'")
+        self.db.commit()
+
+    except psycopg2.InternalError, msg:
+            self.db.rollback()
+            raise DBUpdateError, "Database error, rollback issued. Error message : %s" % (str(msg))
+
index e253967749c948a3d20fe2c6e28053ecad12a7dd..ce35d925ff978fca8bcb11ff06942c06a9e5ed19 100755 (executable)
@@ -240,9 +240,9 @@ def main ():
             Subst["__BCC__"] = "Bcc: " + ", ".join(bcc)
         else:
             Subst["__BCC__"] = "X-Filler: 42"
-        Subst["__CC__"] = "Cc: " + package + "@" + Cnf["Dinstall::PackagesServer"] + "\nX-DAK: dak override"
-        Subst["__ADMIN_ADDRESS__"] = Cnf["Dinstall::MyAdminAddress"]
-        Subst["__DISTRO__"] = Cnf["Dinstall::MyDistribution"]
+        Subst["__CC__"] = "Cc: " + package + "@" + cnf["Dinstall::PackagesServer"] + "\nX-DAK: dak override"
+        Subst["__ADMIN_ADDRESS__"] = cnf["Dinstall::MyAdminAddress"]
+        Subst["__DISTRO__"] = cnf["Dinstall::MyDistribution"]
         Subst["__WHOAMI__"] = utils.whoami()
         Subst["__SOURCE__"] = package
 
index 50b293f5c0e802602d3efee1464bc1acf8d93aa3..e7b1984b20fe06e3be549a93ea4f0790df61004b 100755 (executable)
@@ -45,7 +45,7 @@ from daklib.dak_exceptions import DBUpdateError
 ################################################################################
 
 Cnf = None
-required_database_schema = 25
+required_database_schema = 26
 
 ################################################################################