Problem: I’m using PostgreSQL pg_trgm module which I need to configure by executing
SELECT set_limit(0.5). I need to do this for every connection. I cannot do this in an initializer because connections can be reestablished during the app’s lifetime.
In general, the problem is setting per-connection database options.
Solution: add an after_connect hook that would run after a connection is established and would receive the connection as the parameter.
If you think this is a good idea I can cook up a PR next week.