From 6fce5576ea20f432ce3a9be1bd814e1eaef63a33 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Wed, 11 Aug 2021 09:54:32 +0200 Subject: [PATCH] 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. --- activerecord/CHANGELOG.md | 7 +++++++ activerecord/lib/active_record/internal_metadata.rb | 2 ++ 2 files changed, 9 insertions(+) diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index fe66926685..451f51cbd1 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -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. diff --git a/activerecord/lib/active_record/internal_metadata.rb b/activerecord/lib/active_record/internal_metadata.rb index 628c96ccd9..f7961f9be2 100644 --- a/activerecord/lib/active_record/internal_metadata.rb +++ b/activerecord/lib/active_record/internal_metadata.rb @@ -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?