1 """add per-suite ACL table
2
3 @contact: Debian FTP Master <ftpmaster@debian.org>
4 @copyright: 2023 Emilio Pozuelo Monfort <pochu@debian.org>
5 @license: GNU General Public License version 2 or later
6 """
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 import psycopg2
25 from daklib.dak_exceptions import DBUpdateError
26 from daklib.config import Config
27
28 statements = [
29 """
30 CREATE TABLE acl_per_suite (
31 acl_id INTEGER NOT NULL REFERENCES acl(id) ON DELETE CASCADE,
32 fingerprint_id INTEGER NOT NULL REFERENCES fingerprint(id) ON DELETE CASCADE,
33 suite_id INTEGER NOT NULL REFERENCES suite(id) ON DELETE CASCADE,
34 reason TEXT,
35 created_by_id INTEGER REFERENCES fingerprint(id),
36 created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
37 PRIMARY KEY (acl_id, fingerprint_id, suite_id)
38 )
39 """
40 ]
41
42
43
44
46 print(__doc__)
47 try:
48 cnf = Config()
49
50 c = self.db.cursor()
51
52 for stmt in statements:
53 c.execute(stmt)
54
55 c.execute("UPDATE config SET value = '126' WHERE name = 'db_revision'")
56 self.db.commit()
57
58 except psycopg2.ProgrammingError as msg:
59 self.db.rollback()
60 raise DBUpdateError('Unable to apply sick update 126, rollback issued. Error message: {0}'.format(msg))
61