X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fdakdb%2Fupdate1.py;h=7778b1be7cfe41fbc9e5b9fc70262674885cd341;hb=cd5b29ddfd8de263c085f494b9573d683913f6f3;hp=5c027c51ef01f8d7545aa050e68b6ddb4d7f81b9;hpb=2cd389cc6a64de00500f349db12046d7a87783e2;p=dak.git diff --git a/dak/dakdb/update1.py b/dak/dakdb/update1.py old mode 100644 new mode 100755 index 5c027c51..7778b1be --- a/dak/dakdb/update1.py +++ b/dak/dakdb/update1.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Debian Archive Kit Database Update Script +""" Database Update Script - Saner DM db schema """ # Copyright (C) 2008 Michael Casadevall # This program is free software; you can redistribute it and/or modify @@ -24,7 +24,7 @@ ################################################################################ -import psycopg2 +import psycopg2, time ################################################################################ @@ -32,17 +32,30 @@ def do_update(self): print "Adding DM fields to database" try: - c = self.db.cursor() - c.execute("ALTER TABLE source ADD COLUMN dm_upload_allowed BOOLEAN DEFAULT 'no' NOT NULL;") - c.execute("ALTER TABLE fingerprint ADD COLUMN is_dm BOOLEAN DEFAULT 'false' NOT NULL;") + c = self.db.cursor() + c.execute("ALTER TABLE source ADD COLUMN dm_upload_allowed BOOLEAN DEFAULT 'no' NOT NULL;") + c.execute("ALTER TABLE keyrings ADD COLUMN debian_maintainer BOOLEAN DEFAULT 'false' NOT NULL;") - print "Migrating DM data to source table. This might take some time ..." + print "Migrating DM data to source table. This might take some time ..." - c.execute("UPDATE source SET dm_upload_allowed = 't' WHERE id = (SELECT source FROM src_uploaders);") - c.execute("UPDATE config SET value = '1' WHERE name = 'db_revision'") - self.db.commit() + c.execute("UPDATE source SET dm_upload_allowed = 't' WHERE id IN (SELECT source FROM src_uploaders);") + c.execute("UPDATE config SET value = '1' WHERE name = 'db_revision'") - print "REMINDER: Remember to run the updated byhand-dm crontab to update Debian Maintainer information" + print "Migrating DM uids to normal uids" + c.execute("SELECT uid FROM uid WHERE uid LIKE 'dm:%'") + rows = c.fetchall() + for r in rows: + uid = r[0] + c.execute("UPDATE uid SET uid = '%s' WHERE uid = '%s'" % (uid[3:], uid)) + + self.db.commit() + + print "IMPORTANT: Set the debian_maintainer flag in the config file for keyrings that are DMs!" + print " Failure to do so will result in DM's having full upload abilities!" + print "REMINDER: Remember to run the updated byhand-dm crontab to update Debian Maintainer information" + print "" + print "Pausing for five seconds ..." + time.sleep (5) except psycopg2.ProgrammingError, msg: self.db.rollback()