Module: ActiveRecord::ConnectionAdapters::OracleEnhanced::ColumnDumper

Defined in:
lib/activerecord/monkey_patch/rails5_0.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.

github.com/rsim/oracle-enhanced/blob/v1.7.9/lib/active_record/connection_adapters/oracle_enhanced/column_dumper.rb#L5-L14

Instance Method Summary collapse

Instance Method Details

#column_spec(column) ⇒ Object



152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/activerecord/monkey_patch/rails5_0.rb', line 152

def column_spec(column)
  spec = Hash[prepare_column_options(column).map { |k, v| [k, "#{k}: #{v}"] }]
  spec[:name] = column.name.inspect
  if column.virtual?
    spec[:type] = "virtual"
  else
    spec[:type] = schema_type(column).to_s
  end

  spec[:type] = "datetime" if spec[:type] == "date" # *** This line includes a monky patch condition. ***

  spec
end