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
26 from daklib.dak_exceptions import DBUpdateError
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 c = self.db.cursor()
49
50 for stmt in statements:
51 c.execute(stmt)
52
53 c.execute("UPDATE config SET value = '126' WHERE name = 'db_revision'")
54 self.db.commit()
55
56 except psycopg2.ProgrammingError as msg:
57 self.db.rollback()
58 raise DBUpdateError(
59 "Unable to apply sick update 126, rollback issued. Error message: {0}".format(
60 msg
61 )
62 )
63