5 Remove useless type casts from primary keys to support sqlalchemy's reflection
6 mechanism for all tables. Rename 2 sequences and add 1 primary key.
8 @contact: Debian FTP Master <ftpmaster@debian.org>
9 @copyright: 2011 Torsten Werner <twerner@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 ################################################################################
30 from daklib.dak_exceptions import DBUpdateError
31 from socket import gethostname;
33 ################################################################################
36 Remove useless type casts from primary keys, fix 2 sequences, and add 1
43 # remove useless type casts
44 for table in ('architecture', 'archive', 'bin_associations', \
45 'binaries', 'component', 'dsc_files', 'files', \
46 'fingerprint', 'location', 'maintainer', 'override_type', \
47 'pending_bin_contents', 'priority', 'section', 'source', \
48 'src_associations', 'suite', 'uid'):
49 c.execute("ALTER TABLE %s ALTER id SET DEFAULT nextval('%s_id_seq'::regclass)" % \
53 c.execute("ALTER SEQUENCE known_changes_id_seq RENAME TO changes_id_seq")
54 c.execute("ALTER SEQUENCE queue_files_id_seq RENAME TO build_queue_files_id_seq")
56 # replace unique contraint by primary key
58 "ALTER TABLE bin_contents DROP CONSTRAINT bin_contents_file_key");
59 c.execute("ALTER TABLE bin_contents ADD PRIMARY KEY (file, binary_id)");
61 c.execute("UPDATE config SET value = '41' WHERE name = 'db_revision'")
64 except psycopg2.ProgrammingError, msg:
66 raise DBUpdateError, 'Unable to apply sick update 41, rollback issued. Error message : %s' % (str(msg))