+ print "Adding path to queue table"
+ c.execute("ALTER TABLE queue ADD COLUMN path TEXT")
+ c.execute("SELECT * FROM queue")
+ rows = c.fetchall()
+ seenqueues = {}
+ for row in rows:
+ dir = cnf["Dir::Queue::%s" % row[1]].rstrip('/')
+ seenqueues[row[1].lower()] = 1
+ print "Setting %s queue to use path %s" % (row[1], dir)
+ c.execute("UPDATE queue SET path = %s WHERE id = %s", (dir, row[0]))
+
+ print "Adding missing queues to the queue table"
+ for q in cnf.SubTree("Dir::Queue").keys():
+ qname = q.lower()
+ if qname in seenqueues.keys():
+ continue
+ if qname in ["done", "holding", "reject", "newstage", "btsversiontrack"]:
+ print "Skipping queue %s" % qname
+ continue
+ pth = cnf["Dir::Queue::%s" % qname].rstrip('/')
+ if not os.path.exists(pth):
+ print "Skipping %s as %s does not exist" % (qname, pth)
+ continue
+
+ print "Adding %s queue with path %s" % (qname, pth)
+ c.execute("INSERT INTO queue (queue_name, path) VALUES (%s, %s)", (qname, pth))
+ seenqueues[qname] = 1
+
+ print "Adding queue and approved_for columns to known_changes"
+ c.execute("ALTER TABLE known_changes ADD COLUMN in_queue INT4 REFERENCES queue(id) DEFAULT NULL")
+ c.execute("ALTER TABLE known_changes ADD COLUMN approved_for INT4 REFERENCES queue(id) DEFAULT NULL")
+
+ print "Adding policy queue column to suite table"
+ c.execute("ALTER TABLE suite DROP COLUMN policy_engine")
+ c.execute("ALTER TABLE suite ADD COLUMN policy_queue_id INT4 REFERENCES queue(id) DEFAULT NULL")
+ # Handle some of our common cases automatically
+ if seenqueues.has_key('proposedupdates'):
+ c.execute("""UPDATE suite SET policy_queue_id = (SELECT id FROM queue WHERE queue_name = 'proposedupdates')
+ WHERE suite_name = 'proposed-updates'""")
+
+ if seenqueues.has_key('oldproposedupdates'):
+ c.execute("""UPDATE suite SET policy_queue_id = (SELECT id FROM queue WHERE queue_name = 'oldproposedupdates')
+ WHERE suite_name = 'oldstable-proposed-updates'""")
+
+ print "Committing"