Activerecord adapter for sqlserver is loaded AFTER connection attempt is being made (?)

Hi!

I am deploying a rails 7 app (7.2.2) on ruby 3.3.5 with an AR adapter for sqlserver (activerecord-sqlserver-adapter). As of version 7.2 the adapters have to to register themselves with AR in order to work. It does that but after a connection attempt is being made, i.e. when starting the rails console. The packaged adapters (mysql…) are there in time, the sqlserver one is loaded to late.

It works in developemt mode and on the staging system, not in production.

What am I missing?

You need to read the backtrace to see where this is originating from. Every time I’ve seen this it’s due to referencing AR models within config. If you do need to do something with model[s] on app start it must be done within a to_prepare or after_initialize block.

Reference: