X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fdakdb%2Fupdate116.py;fp=dak%2Fdakdb%2Fupdate116.py;h=7baf0526228fd852ee43d30a14c016bcf5d6cf04;hb=391f5ec09a119131dc846b796ca791f4cecc69e4;hp=0000000000000000000000000000000000000000;hpb=da4fbbe28dc1be591a90f1ca2bb3894e0e931096;p=dak.git diff --git a/dak/dakdb/update116.py b/dak/dakdb/update116.py new file mode 100644 index 00000000..7baf0526 --- /dev/null +++ b/dak/dakdb/update116.py @@ -0,0 +1,38 @@ +""" +Add support for by-hash with a new table and per-suite boolean + +@contact: Debian FTP Master +@copyright: 2016, Julien Cristau +@license: GNU General Public License version 2 or later +""" + +import psycopg2 +from daklib.dak_exceptions import DBUpdateError +from daklib.config import Config + +def do_update(self): + """Add column to store whether to generate by-hash things per suite, + add table to store when by-hash files stopped being referenced + """ + print __doc__ + try: + c = self.db.cursor() + + c.execute("ALTER TABLE suite ADD COLUMN byhash BOOLEAN DEFAULT false") + + c.execute(""" + CREATE TABLE hashfile ( + suite_id INTEGER NOT NULL REFERENCES suite(id) ON DELETE CASCADE, + path TEXT NOT NULL, + unreferenced TIMESTAMP, + PRIMARY KEY (suite_id, path) + ) + """) + + c.execute("UPDATE config SET value = '116' WHERE name = 'db_revision'") + + self.db.commit() + + except psycopg2.ProgrammingError as msg: + self.db.rollback() + raise DBUpdateError('Unable to apply sick update 116, rollback issued. Error message : %s' % (str(msg)))