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 from daklib.dak_exceptions import DBUpdateError
11
12
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()
20
21 c.execute("ALTER TABLE suite ADD COLUMN byhash BOOLEAN DEFAULT false")
22
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 """)
31
32 c.execute("UPDATE config SET value = '116' WHERE name = 'db_revision'")
33
34 self.db.commit()
35
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)))
39