-
- Downloads
An error occurred while retrieving diff 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.
Showing
- config/initializers/database_config.rb 2 additions, 2 deletionsconfig/initializers/database_config.rb
- config/routes.rb 1 addition, 1 deletionconfig/routes.rb
- lib/initializer_connections.rb 18 additions, 15 deletionslib/initializer_connections.rb
- rubocop/cop/database/multiple_databases.rb 1 addition, 0 deletionsrubocop/cop/database/multiple_databases.rb
- spec/config/application_spec.rb 45 additions, 19 deletionsspec/config/application_spec.rb
- spec/lib/initializer_connections_spec.rb 25 additions, 11 deletionsspec/lib/initializer_connections_spec.rb
Loading
Please register or sign in to comment