aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormkanat%kerio.com <>2005-04-23 09:09:22 +0000
committermkanat%kerio.com <>2005-04-23 09:09:22 +0000
commit372be50dde891c803392ed565ba93d5f61190394 (patch)
tree865e4e6f89dda31560f47be5311dc229bdd9bfa8 /Bugzilla/DB/Schema/Mysql.pm
parentBug 290277: Index renaming may fail if misnamed PRIMARY indexes exist (diff)
downloadbugzilla-372be50dde891c803392ed565ba93d5f61190394.tar.gz
bugzilla-372be50dde891c803392ed565ba93d5f61190394.tar.bz2
bugzilla-372be50dde891c803392ed565ba93d5f61190394.zip
Bug 285722: Updates From 2.18- to 2.20+ will not work
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=Tomas.Kopal, a=justdave
Diffstat (limited to 'Bugzilla/DB/Schema/Mysql.pm')
-rw-r--r--Bugzilla/DB/Schema/Mysql.pm11
1 files changed, 9 insertions, 2 deletions
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");
}