Module: ActiveRecord::ConnectionAdapters::ColumnDumper
- Defined in:
- lib/activerecord/monkey_patch/rails5_1.rb
Overview
This is a monkey patch to the problem below. As a result of ‘rails db:schema:dump`, the `DATE` type column expects to return `t.datetime :created_at`. But actually `t.date :created_at` is returned.
Perhaps, converting the ‘DATE` type created in Rails 4 to `TIMESTAMP(6)` type that is used in Rails 5 makes this monkey patch unnecessary.
Original code is the following URL.
Instance Method Summary collapse
Instance Method Details
#column_spec(column) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/activerecord/monkey_patch/rails5_1.rb', line 21 def column_spec(column) # The following 2 lines are a main monkey patch in this method. spec = Hash[(column).map { |k, v| [k, "#{k}: #{v}"] }] schema_type = (column.type == :date) ? :datetime : schema_type_with_virtual(column) [schema_type, (column)] end |