A reliable way of overriding database configuration in a Railtie with Rails 6.1+?

In Rails 6.0 and below I was able to do something like:

class Xxx < Rails::Railtie
  initializer 'xxx', after: 'active_record.initialize_database' do
    ActiveRecord::Base.configurations[Rails.env]['variables']['statement_timeout'] = 42

But since Rails 6.1 database configuration internals have been changed, not to mention introduction of multiple database support so the code above no longer works.

Any suggestion on how to do it “in a Rails way” instead of a hacky way?