summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-09-20 15:32:07 +0800
committerLin Jen-Shin <godfat@godfat.org>2017-09-20 19:39:21 +0800
commit9ab582314852fc6c3f098387ce3a610ea2db0438 (patch)
tree237bfbb2d15c643b8853b4b5e3213c812cf65370
parent7cd2d52829a602606f0b0e9e41498a9bad6fae92 (diff)
downloadgitlab-ce-use-1-for-mysql-default-timestamp.tar.gz
Use now() as default MySQL timestampuse-1-for-mysql-default-timestamp
Because under some configuration and versions, 0 is invalid. See: https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sqlmode_no_zero_date This was discussed in: * https://gitlab.com/gitlab-org/gitlab-ce/issues/36405#note_40120201 * https://gitlab.com/gitlab-org/gitlab-ce/issues/35376#note_40588738 * https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12841#note_40829586
-rw-r--r--changelogs/unreleased/use-1-for-mysql-default-timestamp.yml5
-rw-r--r--config/initializers/active_record_mysql_timestamp.rb3
2 files changed, 7 insertions, 1 deletions
diff --git a/changelogs/unreleased/use-1-for-mysql-default-timestamp.yml b/changelogs/unreleased/use-1-for-mysql-default-timestamp.yml
new file mode 100644
index 00000000000..80a982ebf99
--- /dev/null
+++ b/changelogs/unreleased/use-1-for-mysql-default-timestamp.yml
@@ -0,0 +1,5 @@
+---
+title: Use now() as default timestamp for MySQL
+merge_request: 14383
+author:
+type: fixed
diff --git a/config/initializers/active_record_mysql_timestamp.rb b/config/initializers/active_record_mysql_timestamp.rb
index af74c4ff6fb..b0e53b38978 100644
--- a/config/initializers/active_record_mysql_timestamp.rb
+++ b/config/initializers/active_record_mysql_timestamp.rb
@@ -17,7 +17,8 @@ if Gitlab::Database.mysql?
if options[:null] != false
sql << ' NULL'
elsif options[:column].default.nil?
- sql << ' DEFAULT 0'
+ # See: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/14383
+ sql << ' DEFAULT now()'
end
end