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 ################################################################################
35 ################################################################################
38 print "Adding content fields to database"
42 c.execute("""CREATE TABLE content_file_paths (
43 id serial primary key not null,
44 path text unique not null
47 c.execute("""CREATE TABLE content_file_names (
48 id serial primary key not null,
49 file text unique not null
52 c.execute("""CREATE TABLE content_associations (
54 binary_pkg int4 not null references binaries(id) on delete cascade,
55 filepath int4 not null references content_file_paths(id) on delete cascade,
56 filename int4 not null references content_file_names(id) on delete cascade
59 c.execute("""CREATE FUNCTION comma_concat(text, text) RETURNS text
61 WHEN $2 is null or $2 = '' THEN $1
62 WHEN $1 is null or $1 = '' THEN $2
67 c.execute("""CREATE AGGREGATE comma_separated_list (
74 c.execute("UPDATE config SET value = '2' WHERE name = 'db_revision'")
77 print "REMINDER: Remember to fully regenerate the Contents files before running import-contents"
79 print "Pausing for five seconds ..."
82 except psycopg2.ProgrammingError, msg:
84 print "FATAL: Unable to apply debversion table update 2!"
85 print "Error Message: " + str(msg)
86 print "Database changes have been rolled back."