Commit 5e655777 authored by Max Kanat-Alexander's avatar Max Kanat-Alexander

Bug 578197: [PostgreSQL] Properly associate sequences that had no

column association r=mkanat, a=mkanat (module owner)
parent d873b53d
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment