1"""
2Add support for by-hash with a new table and per-suite boolean
4@contact: Debian FTP Master <ftpmaster@debian.org>
5@copyright: 2016, Julien Cristau <jcristau@debian.org>
6@license: GNU General Public License version 2 or later
7"""
9import psycopg2
10from daklib.dak_exceptions import DBUpdateError
13def do_update(self):
14 """Add column to store whether to generate by-hash things per suite,
15 add table to store when by-hash files stopped being referenced
16 """
17 print(__doc__)
18 try:
19 c = self.db.cursor()
21 c.execute("ALTER TABLE suite ADD COLUMN byhash BOOLEAN DEFAULT false")
23 c.execute("""
24 CREATE TABLE hashfile (
25 suite_id INTEGER NOT NULL REFERENCES suite(id) ON DELETE CASCADE,
26 path TEXT NOT NULL,
27 unreferenced TIMESTAMP,
28 PRIMARY KEY (suite_id, path)
29 )
30 """)
32 c.execute("UPDATE config SET value = '116' WHERE name = 'db_revision'")
34 self.db.commit()
36 except psycopg2.ProgrammingError as msg:
37 self.db.rollback()
38 raise DBUpdateError('Unable to apply sick update 116, rollback issued. Error message : %s' % (str(msg)))