From 372be50dde891c803392ed565ba93d5f61190394 Mon Sep 17 00:00:00 2001 From: "mkanat%kerio.com" <> Date: Sat, 23 Apr 2005 09:09:22 +0000 Subject: Bug 285722: Updates From 2.18- to 2.20+ will not work Patch By Max Kanat-Alexander r=Tomas.Kopal, a=justdave --- Bugzilla/DB/Schema/Mysql.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'Bugzilla/DB/Schema/Mysql.pm') diff --git a/Bugzilla/DB/Schema/Mysql.pm b/Bugzilla/DB/Schema/Mysql.pm index 1ea1d285a..21274f575 100644 --- a/Bugzilla/DB/Schema/Mysql.pm +++ b/Bugzilla/DB/Schema/Mysql.pm @@ -151,9 +151,14 @@ sub _get_create_index_ddl { # MySQL has a simpler ALTER TABLE syntax than ANSI. sub get_alter_column_ddl { - my ($self, $table, $column, $new_def) = @_; + my ($self, $table, $column, $new_def, $set_nulls_to) = @_; my $new_ddl = $self->get_type_ddl($new_def); - return (("ALTER TABLE $table CHANGE COLUMN $column $column $new_ddl")); + my @statements; + push(@statements, "UPDATE $table SET $column = $set_nulls_to + WHERE $column IS NULL") if defined $set_nulls_to; + push(@statements, "ALTER TABLE $table CHANGE COLUMN + $column $column $new_ddl"); + return @statements; } sub get_drop_index_ddl { @@ -281,6 +286,8 @@ sub column_info_to_column { sub get_rename_column_ddl { my ($self, $table, $old_name, $new_name) = @_; my $def = $self->get_type_ddl($self->get_column($table, $old_name)); + # MySQL doesn't like having the PRIMARY KEY statement in a rename. + $def =~ s/PRIMARY KEY//i; return ("ALTER TABLE $table CHANGE COLUMN $old_name $new_name $def"); } -- cgit v1.2.3-24-g4f1b