Skip to content
Snippets Groups Projects
Commit 4ff47c03 authored by Thong Kuah's avatar Thong Kuah 💬 Committed by Ethan Urie
Browse files

Rework with_disabled_database_connections to work with Rails 7.0

In Rails 7.0, `attribute` definitions in models now run at class
definition time, and calls model.connection_db_config. This means
swapping the connection_handler now breaks because there's no valid
connection_pool within with_disabled_database_connections block.

On investigation, `.connection_pool`, and `.connection_db_config` does
not create a database connection (model.connection does).

In order to have this keep working in Rails 7.0, we switch to counting
the number of connections before, and after instead. Also to prevent
re-use of connections, we also disconnect all active connections first.
parent fee620f2
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment