This is a back port gem rails/rails#41856 into Rails 6.1.
Write the following into your Gemfile.
gem 'active_record-postgresql_adapter-virtual_support', git: '[email protected]:tricknotes/active_record-postgresql_adapter-virtual_support.git'
And run
$ bundle