1 """
2 Add support for by-hash with a new table and per-suite boolean
3
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 """
8
9 import psycopg2
10
11 from daklib.dak_exceptions import DBUpdateError
12
13
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()
21
22 c.execute("ALTER TABLE suite ADD COLUMN byhash BOOLEAN DEFAULT false")
23
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 )
34
35 c.execute("UPDATE config SET value = '116' WHERE name = 'db_revision'")
36
37 self.db.commit()
38
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 )
45