X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=dak%2Fdakdb%2Fupdate22.py;h=5c852c67024f0b6a73e4595d51c3ae4f33067ebb;hb=731d594cc9032c1e889c90bc55092536c96e284c;hp=758430c10f65231778102748beec6b72363696e5;hpb=0b38b655a1f91653b66589e43880cea0d1b74157;p=dak.git diff --git a/dak/dakdb/update22.py b/dak/dakdb/update22.py old mode 100755 new mode 100644 index 758430c1..5c852c67 --- a/dak/dakdb/update22.py +++ b/dak/dakdb/update22.py @@ -56,9 +56,12 @@ def do_update(self): print "Adding policy_queue table" c.execute("""CREATE TABLE policy_queue ( - id SERIAL PRIMARY KEY, - queue_name TEXT NOT NULL UNIQUE, - path TEXT NOT NULL)""") + id SERIAL PRIMARY KEY, + queue_name TEXT NOT NULL UNIQUE, + path TEXT NOT NULL, + perms CHAR(4) NOT NULL DEFAULT '0660' CHECK (perms SIMILAR TO '^[0-7][0-7][0-7][0-7]$'), + change_perms CHAR(4) NOT NULL DEFAULT '0660' CHECK (change_perms SIMILAR TO '^[0-7][0-7][0-7][0-7]$') + )""") print "Copying queues" queues = {} @@ -66,7 +69,7 @@ def do_update(self): for q in c.fetchall(): queues[q[0]] = q[1] - if q[1] in ['accepted', 'buildd']: + if q[1] in ['accepted', 'buildd', 'embargoed', 'unembargoed']: # Move to build_queue_table c.execute("""INSERT INTO build_queue (queue_name, path, copy_files) VALUES ('%s', '%s', '%s')""" % (q[1], q[2], q[3])) @@ -95,7 +98,7 @@ def do_update(self): ON DELETE CASCADE""") - c.execute("""ALTER TABLE suite DROP CONSTRAINT suite_policy_queue_fkey""") + c.execute("""ALTER TABLE suite DROP CONSTRAINT suite_policy_queue_id_fkey""") c.execute("""UPDATE suite SET policy_queue_id = (SELECT policy_queue.id FROM policy_queue @@ -166,6 +169,12 @@ def do_update(self): sha1sum TEXT NOT NULL, sha256sum TEXT NOT NULL )""") + c.execute("""CREATE TABLE changes_pending_files_map ( + file_id INT4 NOT NULL REFERENCES changes_pending_files (id), + change_id INT4 NOT NULL REFERENCES known_changes (id), + + PRIMARY KEY (file_id, change_id))""") + c.execute("""CREATE TABLE changes_pending_source ( id SERIAL PRIMARY KEY, change_id INT4 NOT NULL REFERENCES known_changes (id), @@ -198,6 +207,12 @@ def do_update(self): print "Getting rid of old queue table" c.execute("""DROP TABLE queue""") + print "Sorting out permission columns" + c.execute("""UPDATE policy_queue SET perms = '0664' WHERE queue_name IN ('proposedupdates', 'oldproposedupdates')""") + + print "Moving known_changes table" + c.execute("""ALTER TABLE known_changes RENAME TO changes""") + print "Sorting out permissions" for t in ['build_queue', 'policy_queue', 'build_queue_files', @@ -220,6 +235,6 @@ def do_update(self): c.execute("UPDATE config SET value = '22' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.InternalError, msg: + except psycopg2.InternalError as msg: self.db.rollback() - raise DBUpdateError, "Unable to apply queue_build 21, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to apply queue_build 21, rollback issued. Error message : %s" % (str(msg)))