X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fdakdb%2Fupdate15.py;h=7d6b52e7588e3988d52cba08b6e9729e1e92152b;hb=6cc75beccd14c9b39621cb5894d67cec24750405;hp=6cf86cc0d34d8783f084e544d7041b1e7543474f;hpb=0b8842a27c568841dce63ad16084d33567751505;p=dak.git diff --git a/dak/dakdb/update15.py b/dak/dakdb/update15.py old mode 100644 new mode 100755 index 6cf86cc0..7d6b52e7 --- a/dak/dakdb/update15.py +++ b/dak/dakdb/update15.py @@ -43,7 +43,7 @@ def do_update(self): CREATE TABLE src_format ( id SERIAL PRIMARY KEY, format_name TEXT NOT NULL, - unique (format_name) + UNIQUE (format_name) ) """) c.execute("INSERT INTO src_format (format_name) VALUES('1.0')") @@ -52,24 +52,33 @@ def do_update(self): c.execute(""" CREATE TABLE suite_src_formats ( - suite INT4 NOT NULL, - src_format INT4 NOT NULL, - unique (suite, src_format) + suite INT4 NOT NULL REFERENCES suite(id), + src_format INT4 NOT NULL REFERENCES src_format(id), + PRIMARY KEY (suite, src_format) ) """) - print "Authorize all formats on all suites by default" + print "Authorize format 1.0 on all suites by default" c.execute("SELECT id FROM suite") suites = c.fetchall() - c.execute("SELECT id FROM src_format") + c.execute("SELECT id FROM src_format WHERE format_name = '1.0'") formats = c.fetchall() for s in suites: for f in formats: - c.execute("INSERT INTO suite_src_formats (suite, src_format) VALUES('%s', '%s')" % (s[0], f[0])) + c.execute("INSERT INTO suite_src_formats (suite, src_format) VALUES(%s, %s)", (s[0], f[0])) + + print "Authorize all other formats on tpu, unstable & experimental by default" + c.execute("SELECT id FROM suite WHERE suite_name IN ('testing-proposed-updates', 'unstable', 'experimental')") + suites = c.fetchall() + c.execute("SELECT id FROM src_format WHERE format_name != '1.0'") + formats = c.fetchall() + for s in suites: + for f in formats: + c.execute("INSERT INTO suite_src_formats (suite, src_format) VALUES(%s, %s)", (s[0], f[0])) c.execute("UPDATE config SET value = '15' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, "Unable to apply source format update 15, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to apply source format update 15, rollback issued. Error message : %s" % (str(msg)))