Module: ActiveRecord::Migration::CockroachDB::Compatibility::V7_0Patch

Defined in:
lib/active_record/migration/cockroachdb/compatibility.rb

Instance Method Summary collapse

Instance Method Details

#compatible_timestamp_type(type, connection) ⇒ Object

Override. Use “CockroachDB” instead of “PostgreSQL”



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/active_record/migration/cockroachdb/compatibility.rb', line 26

def compatible_timestamp_type(type, connection)
  if connection.adapter_name == "CockroachDB"
    # For Rails <= 6.1, :datetime was aliased to :timestamp
    # See: https://github.com/rails/rails/blob/v6.1.3.2/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb#L108
    # From Rails 7 onwards, you can define what :datetime resolves to (the default is still :timestamp)
    # See `ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.datetime_type`
    type.to_sym == :datetime ? :timestamp : type
  else
    type
  end
end