I have a setup with one primary writer db and a readonly replica. I’ve looked into the autoswitching mechanism provided by rails, but it does not work for me since it decides based on the http method. We have a huge monolith and going over all endpoints to fit this technique is not viable. I would think that selecting the database based on the raw sql that would run could be feasable, taking into account transactions and how long has passed since the last write (to account for replication lag). Does this make sense? How should i approach implementing something like this? I looked into inheriting Middleware::DatabaseSelector however the context injected there always seems related to the request and not the sql.