summaryrefslogtreecommitdiffstats
path: root/Bugzilla/DB/Schema
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2006-11-01 08:27:31 +0100
committermkanat%bugzilla.org <>2006-11-01 08:27:31 +0100
commit89edfad4a52a2924dbf2d67d5609870e1200f7d3 (patch)
tree12d28d0e870419bb989488ad7f9ced11742cb012 /Bugzilla/DB/Schema
parente698452f3a2e5a04e291b880c2d823b098c0714a (diff)
downloadbugzilla-89edfad4a52a2924dbf2d67d5609870e1200f7d3.tar.gz
bugzilla-89edfad4a52a2924dbf2d67d5609870e1200f7d3.tar.xz
Bug 358956: [PostgreSQL] Sequences need to be renamed when their field is renamed
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> (module owner) a=myk
Diffstat (limited to 'Bugzilla/DB/Schema')
-rw-r--r--Bugzilla/DB/Schema/Pg.pm12
1 files changed, 10 insertions, 2 deletions
diff --git a/Bugzilla/DB/Schema/Pg.pm b/Bugzilla/DB/Schema/Pg.pm
index 21b0c6d96..0101a1e43 100644
--- a/Bugzilla/DB/Schema/Pg.pm
+++ b/Bugzilla/DB/Schema/Pg.pm
@@ -92,8 +92,16 @@ sub _initialize {
sub get_rename_column_ddl {
my ($self, $table, $old_name, $new_name) = @_;
-
- return ("ALTER TABLE $table RENAME COLUMN $old_name TO $new_name");
+ my @sql = ("ALTER TABLE $table RENAME COLUMN $old_name TO $new_name");
+ my $def = $self->get_column_abstract($table, $old_name);
+ if ($def->{TYPE} =~ /SERIAL/i) {
+ # We have to rename the series also, and fix the default of the series.
+ push(@sql, "ALTER TABLE ${table}_${old_name}_seq
+ RENAME TO ${table}_${new_name}_seq");
+ push(@sql, "ALTER TABLE $table ALTER COLUMN $new_name
+ SET DEFAULT NEXTVAL('${table}_${new_name}_seq')");
+ }
+ return @sql;
}
sub _get_alter_type_sql {