Use Gitlab::Database::SharedModel for connection handling
What does this MR do and why?
This change improves how database connections are managed in test code for background migration workers. Previously, some database operations were executed directly without proper connection context, which could cause issues. The update wraps all database operations (creating tables, inserting test data, and defining models) within a proper connection context using Gitlab::Database::SharedModel.using_connection().
This ensures that all database interactions use the correct connection consistently and safely. The change also adds a safety measure to drop any existing test table before creating a new one, preventing potential conflicts from previous test runs.
References
Screenshots or screen recordings
| Before | After |
|---|---|
How to set up and validate locally
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.
Related to #568071 (closed)