5 Debian Archive Kit Database Update Script
6 Copyright © 2008 Michael Casadevall <mcasadevall@debian.org>
7 Copyright © 2008 Roger Leigh <rleigh@debian.org>
9 Debian Archive Kit Database Update Script 2
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 ################################################################################
28 # <tomv_w> really, if we want to screw ourselves, let's find a better way.
29 # <Ganneff> rm -rf /srv/ftp.debian.org
31 ################################################################################
36 ################################################################################
39 print "Adding content fields to database"
43 c.execute("""CREATE TABLE content_file_paths (
44 id serial primary key not null,
45 path text unique not null
48 c.execute("""CREATE TABLE content_file_names (
49 id serial primary key not null,
50 file text unique not null
53 c.execute("""CREATE TABLE content_associations (
55 binary_pkg int4 not null references binaries(id) on delete cascade,
56 filepath int4 not null references content_file_paths(id) on delete cascade,
57 filename int4 not null references content_file_names(id) on delete cascade
60 c.execute("""CREATE TABLE pending_content_associations (
62 package text not null,
63 version debversion not null,
64 filepath int4 not null references content_file_paths(id) on delete cascade,
65 filename int4 not null references content_file_names(id) on delete cascade
68 c.execute("""CREATE FUNCTION comma_concat(text, text) RETURNS text
70 WHEN $2 is null or $2 = '' THEN $1
71 WHEN $1 is null or $1 = '' THEN $2
76 c.execute("""CREATE AGGREGATE comma_separated_list (
83 c.execute( "CREATE INDEX content_assocaitions_binary ON content_associations(binary_pkg)" )
85 c.execute("UPDATE config SET value = '6' WHERE name = 'db_revision'")
88 print "REMINDER: Remember to fully regenerate the Contents files before running import-contents"
90 print "Pausing for five seconds ..."
93 except psycopg2.ProgrammingError, msg:
95 raise DBUpdateError, "Unable to appy debversion updates, rollback issued. Error message : %s" % (str(msg))