]> git.decadent.org.uk Git - dak.git/blobdiff - dak/dakdb/update43.py
Merge branch 'pu/xz-for-indices'
[dak.git] / dak / dakdb / update43.py
old mode 100755 (executable)
new mode 100644 (file)
index b9c7f58..430cc35
@@ -2,11 +2,10 @@
 # coding=utf8
 
 """
-Remove old contents tables that are no longer needed by the current
-implementation.
+Fix up constraints for pg 9.0
 
 @contact: Debian FTP Master <ftpmaster@debian.org>
-@copyright: 2011 Torsten Werner <twerner@debian.org>
+@copyright: 2011 Mark Hymers <mhy@debian.org>
 @license: GNU General Public License version 2 or later
 """
 
@@ -33,20 +32,20 @@ from socket import gethostname;
 ################################################################################
 def do_update(self):
     """
-    Remove old contents tables that are no longer needed by the current
-    implementation.
+    Fix up constraints for pg 9.0
     """
     print __doc__
     try:
         c = self.db.cursor()
 
-        # remove useless type casts
-        for table in ('pending_bin_contents', 'deb_contents', 'udeb_contents'):
-            c.execute("DROP TABLE %s" % table)
+        c.execute("ALTER TABLE policy_queue DROP constraint policy_queue_perms_check")
+        c.execute("ALTER TABLE policy_queue DROP constraint policy_queue_change_perms_check")
+        c.execute("ALTER TABLE policy_queue ADD CONSTRAINT policy_queue_perms_check CHECK (perms SIMILAR TO '[0-7][0-7][0-7][0-7]')")
+        c.execute("ALTER TABLE policy_queue ADD CONSTRAINT policy_queue_change_perms_check CHECK (change_perms SIMILAR TO '[0-7][0-7][0-7][0-7]')")
 
         c.execute("UPDATE config SET value = '43' WHERE name = 'db_revision'")
         self.db.commit()
 
-    except psycopg2.ProgrammingError, msg:
+    except psycopg2.ProgrammingError as msg:
         self.db.rollback()
-        raise DBUpdateError, 'Unable to apply sick update 43, rollback issued. Error message : %s' % (str(msg))
+        raise DBUpdateError('Unable to apply update 43, rollback issued. Error message : %s' % (str(msg)))