diff options
Diffstat (limited to 'Bugzilla/DB/Schema/Mysql.pm')
-rw-r--r-- | Bugzilla/DB/Schema/Mysql.pm | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/Bugzilla/DB/Schema/Mysql.pm b/Bugzilla/DB/Schema/Mysql.pm index b0a40586f..bcc663e83 100644 --- a/Bugzilla/DB/Schema/Mysql.pm +++ b/Bugzilla/DB/Schema/Mysql.pm @@ -119,7 +119,7 @@ sub _initialize { LONGBLOB => 'longblob', - DATETIME => 'datetime', + DATETIME => 'timestamp', DATE => 'date', }; @@ -396,4 +396,25 @@ sub get_rename_column_ddl { return ("ALTER TABLE $table CHANGE COLUMN $old_name $new_name $def"); } +sub get_type_ddl { + my $self = shift; + my $type_ddl = $self->SUPER::get_type_ddl(@_); + + # TIMESTAMPS as of 5.6.6 still default to + # 'NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP' + # unless explicitly setup in the table definition. This will change in future releases + # and can be disabled by using 'explicit_defaults_for_timestamp = 1' in my.cnf. + # So instead, we explicitly setup TIMESTAMP types to not be automatic. + if ($type_ddl =~ /^timestamp/i) { + if ($type_ddl !~ /NOT NULL/) { + $type_ddl .= ' NULL DEFAULT NULL'; + } + if ($type_ddl =~ /NOT NULL/ && $type_ddl !~ /DEFAULT/) { + $type_ddl .= ' DEFAULT CURRENT_TIMESTAMP'; + } + } + + return $type_ddl; +} + 1; |