Here's the recent syntax.
# How to specify particular databases
DatabaseCleaner[:active_record, db: :two]
# You may also pass in the model directly:
DatabaseCleaner[:active_record, db: ModelWithDifferentConnection]
ref: https://github.com/DatabaseCleaner/database_cleaner?tab=readme-ov-file#how-to-use-with-multiple-orms
For me db: :two syntax didn't work, but db: ModelWithDifferentConnection worked as expected.
You can define another Record class and use that as db.
class OtherRecord < ActiveRecord::Base
self.abstract_class = true
connects_to database: { writing: :other, reading: :other}
end
# spec/rails_helper.rb hook
DatabaseCleaner[:active_record, db: OtherRecord]