3 # Debian Archive Kit Database Update Script 2
4 # Copyright (C) 2009 Michael Casadevall <mcasadevall@debian.org>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 ################################################################################
22 # <tomv_w> really, if we want to screw ourselves, let's find a better way.
23 # <Ganneff> rm -rf /srv/ftp.debian.org
25 ################################################################################
29 ################################################################################
32 print "Adding content fields to database"
36 c.execute("""CREATE TABLE content_file_paths (
37 id serial primary key not null,
38 path text unique not null
41 c.execute("""CREATE TABLE content_file_names (
42 id serial primary key not null,
43 file text unique not null
46 c.execute("""CREATE TABLE content_associations (
48 binary_pkg int4 not null references binaries(id) on delete cascade,
49 filepath int4 not null references content_file_paths(id) on delete cascade,
50 filename int4 not null references content_file_names(id) on delete cascade
53 c.execute("""CREATE FUNCTION comma_concat(text, text) RETURNS text
55 WHEN $2 is null or $2 = '' THEN $1
56 WHEN $1 is null or $1 = '' THEN $2
61 c.execute("""CREATE AGGREGATE comma_separated_list (
68 c.execute("UPDATE config SET value = '2' WHERE name = 'db_revision'")
71 print "REMINDER: Remember to fully regenerate the Contents files before running import-contents"
73 print "Pausing for five seconds ..."
76 except psycopg2.ProgrammingError, msg:
78 print "FATAL: Unable to apply content table update 2!"
79 print "Error Message: " + str(msg)
80 print "Database changes have been rolled back."