ActiveContext: reload on change and other minor updates

What does this MR do and why?

Adds two new methods:

  • collection.name_without_prefix: needed for running the drop_collection migration inline
  • connection.adapter which can be run using an active or inactive connection. This is needed to run cleanup if a connection is deactivated.

Also reloads the adapter when a connection is saved. This is to ensure we always use the adapter with the right connection and options.

References

How to set up and validate locally

  • Create a connection, activate it and run migrations
  • Test that ActiveContext.adapter.connection.collections.first.name_without_prefix is code
  • Test that connection.adapter returns the right adapter and options
  • Deactivate the connection: connection.deactivate!
  • Test that connection.adapter still returns the right adapter and options
  • Create a new connection and activate it
  • Test that ActiveContext.adapter.connection is the new connection

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports

Loading