diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2018-06-25 16:03:24 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2018-06-25 16:03:24 +0300 |
commit | 7668c9660fe30338044afd7886a0fac56e6e82b9 (patch) | |
tree | 9cff3242eae13112b8953d44dec24e303beab673 /config | |
parent | 901159bbae51d818cd6f643da713eee8319923da (diff) | |
parent | 1ec356a0b5b6594ef0df3fb764cb57c0859ca86f (diff) |
Merge branch 'jprovazn-rails5-mysql-datetime' into 'master'
[Rails5] Fix MysqlDateTimeWithTimeZone in rails 5
Closes #46275
See merge request gitlab-org/gitlab-ce!19613
Diffstat (limited to 'config')
-rw-r--r-- | config/application.rb | 17 | ||||
-rw-r--r-- | config/initializers/active_record_data_types.rb | 2 |
2 files changed, 12 insertions, 7 deletions
diff --git a/config/application.rb b/config/application.rb index 202e5d5e327..d9483cd806d 100644 --- a/config/application.rb +++ b/config/application.rb @@ -5,6 +5,12 @@ require 'rails/all' Bundler.require(:default, Rails.env) module Gitlab + # This method is used for smooth upgrading from the current Rails 4.x to Rails 5.0. + # https://gitlab.com/gitlab-org/gitlab-ce/issues/14286 + def self.rails5? + ENV["RAILS5"].in?(%w[1 true]) + end + class Application < Rails::Application require_dependency Rails.root.join('lib/gitlab/redis/wrapper') require_dependency Rails.root.join('lib/gitlab/redis/cache') @@ -14,6 +20,11 @@ module Gitlab require_dependency Rails.root.join('lib/gitlab/current_settings') require_dependency Rails.root.join('lib/gitlab/middleware/read_only') + # This needs to be loaded before DB connection is made + # to make sure that all connections have NO_ZERO_DATE + # setting disabled + require_dependency Rails.root.join('lib/mysql_zero_date') + # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. @@ -211,10 +222,4 @@ module Gitlab Gitlab::Routing.add_helpers(MilestonesRoutingHelper) end end - - # This method is used for smooth upgrading from the current Rails 4.x to Rails 5.0. - # https://gitlab.com/gitlab-org/gitlab-ce/issues/14286 - def self.rails5? - ENV["RAILS5"].in?(%w[1 true]) - end end diff --git a/config/initializers/active_record_data_types.rb b/config/initializers/active_record_data_types.rb index fda13d0c4cb..717e30b5b7e 100644 --- a/config/initializers/active_record_data_types.rb +++ b/config/initializers/active_record_data_types.rb @@ -65,7 +65,7 @@ elsif Gitlab::Database.mysql? prepend RegisterDateTimeWithTimeZone # Add the class `DateTimeWithTimeZone` so we can map `timestamp` to it. - class MysqlDateTimeWithTimeZone < MysqlDateTime + class MysqlDateTimeWithTimeZone < (Gitlab.rails5? ? ActiveRecord::Type::DateTime : MysqlDateTime) def type :datetime_with_timezone end |