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# This program is free software; you can redistribute it and/or modify 

9# it under the terms of the GNU General Public License as published by 

10# the Free Software Foundation; either version 2 of the License, or 

11# (at your option) any later version. 

12 

13# This program is distributed in the hope that it will be useful, 

14# but WITHOUT ANY WARRANTY; without even the implied warranty of 

15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

16# GNU General Public License for more details. 

17 

18# You should have received a copy of the GNU General Public License 

19# along with this program; if not, write to the Free Software 

20# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 

21 

22################################################################################ 

23 

24import psycopg2 

25from daklib.dak_exceptions import DBUpdateError 

26from daklib.config import Config 

27 

28sequences = { 

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 

64def do_update(self): 

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))