Sha256: ecdd1527d2d84adccce84c54993ba0b0c5358afbdfdd0d19a2cfa9face157c5d

Contents?: true

Size: 588 Bytes

Versions: 1

Compression:

Stored size: 588 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 defined?(ActiveRecord)
  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kono_utils-0.15.9 config/initializers/time.rb