Sha256: b673b296a752536f34bcb4111e9f60a53650511c49eb872e16ec3ef373f4f647

Contents?: true

Size: 544 Bytes

Versions: 4

Compression:

Stored size: 544 Bytes

Contents

# NOTE: Apparently, this initializer is not necessary with Rails 4.2.5 and up.
# It just works with the correct database type DATETIME(6).

# Where 6N is the number of places after the decimal (.)
# For less precision (eg. miliseconds), change 6N to 3N
if ActiveRecord::Base.connection.instance_of? ActiveRecord::ConnectionAdapters::Mysql2Adapter
  version = Gem::Version.new(Mysql2::Client.info.fetch(:version))
  min_vresion = Gem::Version.new('5.6.4')
  if version>=min_vresion
    Time::DATE_FORMATS[:db] = '%Y-%m-%d %H:%M:%S.%6N'
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kono_utils-0.15.8 config/initializers/time.rb
kono_utils-0.15.7 config/initializers/time.rb
kono_utils-0.15.6 config/initializers/time.rb
kono_utils-0.15.5 config/initializers/time.rb