1 """set owner tables for sequences
2
3 @contact: Debian FTP Master <ftpmaster@debian.org>
4 @copyright: 2018, Bastian Blank <waldi@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 sequences = {
29 'acl_id_seq': 'acl.id',
30 'architecture_id_seq': 'architecture.id',
31 'archive_id_seq': 'archive.id',
32 'bin_associations_id_seq': 'bin_associations.id',
33 'binaries_id_seq': 'binaries.id',
34 'build_queue_id_seq': 'build_queue.id',
35 'changelogs_text_id_seq': 'changelogs_text.id',
36 'changes_id_seq': 'changes.id',
37 'component_id_seq': 'component.id',
38 'component_ordering_seq': 'component.ordering',
39 'config_id_seq': 'config.id',
40 'dsc_files_id_seq': 'dsc_files.id',
41 'files_id_seq': 'files.id',
42 'fingerprint_id_seq': 'fingerprint.id',
43 'keyrings_id_seq': 'keyrings.id',
44 'maintainer_id_seq': 'maintainer.id',
45 'metadata_keys_key_id_seq': 'metadata_keys.key_id',
46 'new_comments_id_seq': 'new_comments.id',
47 'override_type_id_seq': 'override_type.id',
48 'policy_queue_byhand_file_id_seq': 'policy_queue_byhand_file.id',
49 'policy_queue_id_seq': 'policy_queue.id',
50 'policy_queue_upload_id_seq': 'policy_queue_upload.id',
51 'priority_id_seq': 'priority.id',
52 'section_id_seq': 'section.id',
53 'source_id_seq': 'source.id',
54 'src_associations_id_seq': 'src_associations.id',
55 'src_format_id_seq': 'src_format.id',
56 'src_uploaders_id_seq': 'src_uploaders.id',
57 'suite_id_seq': 'suite.id',
58 'uid_id_seq': 'uid.id',
59 }
60
61
62
63
65 print(__doc__)
66 try:
67 cnf = Config()
68
69 c = self.db.cursor()
70
71 for i in sequences.items():
72 c.execute("ALTER SEQUENCE {0} OWNED BY {1}".format(*i))
73
74 c.execute("UPDATE config SET value = '118' WHERE name = 'db_revision'")
75 self.db.commit()
76
77 except psycopg2.ProgrammingError as msg:
78 self.db.rollback()
79 raise DBUpdateError('Unable to apply sick update 118, rollback issued. Error message: {0}'.format(msg))
80