1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Set record_timestamps = true in AR::InternalMetadata

Fix: https://github.com/rails/rails/issues/42983

The usefulness of these timestamps is a bit questionable,
but I suppose they could be useful for debugging, and
removing them would require to ship a migration etc.

Since `record_timestamps` is now a `class_attribute` we
can simply force it to `true` in just that class.
This commit is contained in:
Jean Boussier 2021-08-11 09:54:32 +02:00
parent ee98178ea5
commit 6fce5576ea
2 changed files with 9 additions and 0 deletions

View file

@ -1,3 +1,10 @@
* Fix `ActiveRecord::InternalMetadata` to not be broken by `config.active_record.record_timestamps = false`
Since the model always create the timestamp columns, it has to set them, otherwise it breaks
various DB management tasks.
Fixes #42983
* Add `ActiveRecord::QueryLogs`.
Configurable tags can be automatically added to all SQL queries generated by Active Record.

View file

@ -10,6 +10,8 @@ module ActiveRecord
# This is enabled by default. To disable this functionality set
# `use_metadata_table` to false in your database configuration.
class InternalMetadata < ActiveRecord::Base # :nodoc:
self.record_timestamps = true
class << self
def enabled?
ActiveRecord::Base.connection.use_metadata_table?