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 ################################################################################
36 from daklib.dak_exceptions import DBUpdateError
38 ################################################################################
41 print "Adding content fields to database"
45 c.execute("""CREATE TABLE content_file_paths (
46 id serial primary key not null,
47 path text unique not null
50 c.execute("""CREATE TABLE content_file_names (
51 id serial primary key not null,
52 file text unique not null
55 c.execute("""CREATE TABLE content_associations (
57 binary_pkg int4 not null references binaries(id) on delete cascade,
58 filepath int4 not null references content_file_paths(id) on delete cascade,
59 filename int4 not null references content_file_names(id) on delete cascade
62 c.execute("""CREATE TABLE pending_content_associations (
64 package text not null,
65 version debversion not null,
66 filepath int4 not null references content_file_paths(id) on delete cascade,
67 filename int4 not null references content_file_names(id) on delete cascade
70 c.execute("""CREATE FUNCTION comma_concat(text, text) RETURNS text
72 WHEN $2 is null or $2 = '' THEN $1
73 WHEN $1 is null or $1 = '' THEN $2
78 c.execute("""CREATE AGGREGATE comma_separated_list (
85 c.execute( "CREATE INDEX content_assocaitions_binary ON content_associations(binary_pkg)" )
87 c.execute("UPDATE config SET value = '6' WHERE name = 'db_revision'")
90 except psycopg2.ProgrammingError, msg:
92 raise DBUpdateError, "Unable to appy debversion updates, rollback issued. Error message : %s" % (str(msg))