|
1
|
+#!/usr/bin/env python
|
|
2
|
+# coding=utf8
|
|
3
|
+
|
|
4
|
+"""remove unused database objects
|
|
5
|
+
|
|
6
|
+@contact: Debian FTP Master <ftpmaster@debian.org>
|
|
7
|
+@copyright: 2018, Bastian Blank <waldi@debian.org>
|
|
8
|
+@license: GNU General Public License version 2 or later
|
|
9
|
+"""
|
|
10
|
+
|
|
11
|
+# This program is free software; you can redistribute it and/or modify
|
|
12
|
+# it under the terms of the GNU General Public License as published by
|
|
13
|
+# the Free Software Foundation; either version 2 of the License, or
|
|
14
|
+# (at your option) any later version.
|
|
15
|
+
|
|
16
|
+# This program is distributed in the hope that it will be useful,
|
|
17
|
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
+# GNU General Public License for more details.
|
|
20
|
+
|
|
21
|
+# You should have received a copy of the GNU General Public License
|
|
22
|
+# along with this program; if not, write to the Free Software
|
|
23
|
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
24
|
+
|
|
25
|
+################################################################################
|
|
26
|
+
|
|
27
|
+import psycopg2
|
|
28
|
+from daklib.dak_exceptions import DBUpdateError
|
|
29
|
+from daklib.config import Config
|
|
30
|
+
|
|
31
|
+views = [
|
|
32
|
+ 'obsolete_all_associations',
|
|
33
|
+ 'obsolete_any_associations',
|
|
34
|
+ 'obsolete_any_by_all_associations',
|
|
35
|
+ 'obsolete_src_associations',
|
|
36
|
+ 'almost_obsolete_all_associations',
|
|
37
|
+ 'almost_obsolete_src_associations',
|
|
38
|
+ 'newest_all_associations',
|
|
39
|
+ 'newest_any_associations',
|
|
40
|
+ 'any_associations_source',
|
|
41
|
+ 'binaries_suite_arch',
|
|
42
|
+ 'file_arch_suite',
|
|
43
|
+ 'src_associations_bin',
|
|
44
|
+ 'suite_arch_by_name',
|
|
45
|
+]
|
|
46
|
+
|
|
47
|
+sequences = [
|
|
48
|
+ 'location_id_seq',
|
|
49
|
+]
|
|
50
|
+
|
|
51
|
+################################################################################
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+def do_update(self):
|
|
55
|
+ print __doc__
|
|
56
|
+ try:
|
|
57
|
+ cnf = Config()
|
|
58
|
+
|
|
59
|
+ c = self.db.cursor()
|
|
60
|
+
|
|
61
|
+ for i in views:
|
|
62
|
+ c.execute("DROP VIEW {0}".format(i))
|
|
63
|
+
|
|
64
|
+ for i in sequences:
|
|
65
|
+ c.execute("DROP SEQUENCE {0}".format(i))
|
|
66
|
+
|
|
67
|
+ c.execute("UPDATE config SET value = '119' WHERE name = 'db_revision'")
|
|
68
|
+ self.db.commit()
|
|
69
|
+
|
|
70
|
+ except psycopg2.ProgrammingError as msg:
|
|
71
|
+ self.db.rollback()
|
|
72
|
+ raise DBUpdateError('Unable to apply sick update 119, rollback issued. Error message: {0}'.format(msg))
|