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
11from daklib.dak_exceptions import DBUpdateError
14def do_update(self):
15 """Add column to store whether to generate by-hash things per suite,
16 add table to store when by-hash files stopped being referenced
17 """
18 print(__doc__)
19 try:
20 c = self.db.cursor()
22 c.execute("ALTER TABLE suite ADD COLUMN byhash BOOLEAN DEFAULT false")
24 c.execute(
25 """
26 CREATE TABLE hashfile (
27 suite_id INTEGER NOT NULL REFERENCES suite(id) ON DELETE CASCADE,
28 path TEXT NOT NULL,
29 unreferenced TIMESTAMP,
30 PRIMARY KEY (suite_id, path)
31 )
32 """
33 )
35 c.execute("UPDATE config SET value = '116' WHERE name = 'db_revision'")
37 self.db.commit()
39 except psycopg2.ProgrammingError as msg:
40 self.db.rollback()
41 raise DBUpdateError(
42 "Unable to apply sick update 116, rollback issued. Error message : %s"
43 % (str(msg))
44 )