summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorMax Kanat-Alexander <mkanat@bugzilla.org>2010-07-13 01:17:51 +0200
committerMax Kanat-Alexander <mkanat@bugzilla.org>2010-07-13 01:17:51 +0200
commit5e655777fbdbb93348807308a045fca3cb4c7ab2 (patch)
treebc6cf31cde1460cb7f264acc2c05a079532380e8 /Bugzilla
parentd873b53dd1f51bdd852119ee3613224251bce3c8 (diff)
downloadbugzilla-5e655777fbdbb93348807308a045fca3cb4c7ab2.tar.gz
bugzilla-5e655777fbdbb93348807308a045fca3cb4c7ab2.tar.xz
Bug 578197: [PostgreSQL] Properly associate sequences that had no
column association r=mkanat, a=mkanat (module owner)
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/DB/Pg.pm21
1 files changed, 21 insertions, 0 deletions
diff --git a/Bugzilla/DB/Pg.pm b/Bugzilla/DB/Pg.pm
index 7aaafd88f..8ed7368aa 100644
--- a/Bugzilla/DB/Pg.pm
+++ b/Bugzilla/DB/Pg.pm
@@ -278,6 +278,27 @@ END
$self->do("ALTER TABLE fielddefs ALTER COLUMN id
SET DEFAULT NEXTVAL('fielddefs_id_seq')");
}
+
+ # Certain sequences got upgraded before we required Pg 8.3, and
+ # so they were not properly associated with their columns.
+ my @tables = $self->bz_table_list_real;
+ foreach my $table (@tables) {
+ my @columns = $self->bz_table_columns_real($table);
+ foreach my $column (@columns) {
+ # All our SERIAL pks have "id" in their name at the end.
+ next unless $column =~ /id$/;
+ my $sequence = "${table}_${column}_seq";
+ if ($self->bz_sequence_exists($sequence)) {
+ my $is_associated = $self->selectrow_array(
+ 'SELECT pg_get_serial_sequence(?,?)',
+ undef, $table, $column);
+ next if $is_associated;
+ print "Fixing $sequence to be associated"
+ . " with $table.$column...\n";
+ $self->do("ALTER SEQUENCE $sequence OWNED BY $table.$column");
+ }
+ }
+ }
}
# Renames things that differ only in case.