summaryrefslogtreecommitdiffstats
path: root/Bugzilla/DB/Schema
diff options
context:
space:
mode:
authormkanat%kerio.com <>2005-04-23 11:09:22 +0200
committermkanat%kerio.com <>2005-04-23 11:09:22 +0200
commit372be50dde891c803392ed565ba93d5f61190394 (patch)
tree865e4e6f89dda31560f47be5311dc229bdd9bfa8 /Bugzilla/DB/Schema
parentc6c829a7f63c7048705d5bf86c60df015993851e (diff)
downloadbugzilla-372be50dde891c803392ed565ba93d5f61190394.tar.gz
bugzilla-372be50dde891c803392ed565ba93d5f61190394.tar.xz
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')
-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");
}