From 35df2cd5bc44b1f369ca6d32dfe1c600c1608dc4 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Sat, 14 May 2016 14:09:38 +0000 Subject: Bug 232193 - bmo's systems (webheads, database, etc) should use UTC natively for o/s timezone and date storage --- Bugzilla/DB/Schema/Mysql.pm | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'Bugzilla/DB/Schema') 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; -- cgit v1.2.3-24-g4f1b