7 @contact: Debian FTP Master <ftpmaster@debian.org>
8 @copyright: 2008 Michael Casadevall <mcasadevall@debian.org>
9 @copyright: 2008 Roger Leigh <rleigh@debian.org>
10 @license: GNU General Public License version 2 or later
13 # This program is free software; you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation; either version 2 of the License, or
16 # (at your option) any later version.
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write to the Free Software
25 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 ################################################################################
29 # <tomv_w> really, if we want to screw ourselves, let's find a better way.
30 # <Ganneff> rm -rf /srv/ftp.debian.org
32 ################################################################################
37 ################################################################################
40 print "Adding content fields to database"
44 c.execute("""CREATE TABLE content_file_paths (
45 id serial primary key not null,
46 path text unique not null
49 c.execute("""CREATE TABLE content_file_names (
50 id serial primary key not null,
51 file text unique not null
54 c.execute("""CREATE TABLE content_associations (
56 binary_pkg int4 not null references binaries(id) on delete cascade,
57 filepath int4 not null references content_file_paths(id) on delete cascade,
58 filename int4 not null references content_file_names(id) on delete cascade
61 c.execute("""CREATE TABLE pending_content_associations (
63 package text not null,
64 version debversion not null,
65 filepath int4 not null references content_file_paths(id) on delete cascade,
66 filename int4 not null references content_file_names(id) on delete cascade
69 c.execute("""CREATE FUNCTION comma_concat(text, text) RETURNS text
71 WHEN $2 is null or $2 = '' THEN $1
72 WHEN $1 is null or $1 = '' THEN $2
77 c.execute("""CREATE AGGREGATE comma_separated_list (
84 c.execute( "CREATE INDEX content_assocaitions_binary ON content_associations(binary_pkg)" )
86 c.execute("UPDATE config SET value = '6' WHERE name = 'db_revision'")
89 except psycopg2.ProgrammingError, msg:
91 raise DBUpdateError, "Unable to appy debversion updates, rollback issued. Error message : %s" % (str(msg))