Flag GitLab objects in schemas outside the search path
What does this MR do and why?
Follow-up to !245566 (merged)
This MR adds a gitlab_objects_outside_search_path warning to Gitlab::Database::DatabaseInformation. Every schema that is not a search-path candidate is cross-referenced against the GitLab schema dictionary (Gitlab::Database::GitlabSchema.table_schema), and a warning is reported when one holds recognized GitLab objects. GitLab never resolves unqualified references against such schemas, so these objects are never used — they are typically leftovers from a restore or a migration into the wrong schema.
Partition schemas (gitlab_partitions_dynamic, gitlab_partitions_static) are exempt because GitLab keeps partitions there by design, outside the search path.
The finding renders through the existing findings UI on /admin/database_diagnostics, so no frontend change is needed.
Related to #611068 (closed)
Screenshots or screen recordings
The new finding on /admin/database_diagnostics, after the setup in the next section. Expand Details on the Search path row to see it.
How to set up and validate locally
All statements target the main development database (gitlabhq_development).
-
Create a schema with a GitLab object, without touching the
search_path:CREATE SCHEMA foobar; CREATE TABLE foobar.users (id int); -
In a Rails console:
Gitlab::Database::DatabaseInformation.executeThe
findingsarray now contains agitlab_objects_outside_search_pathwarning namingfoobar. Before this change it was empty. -
Replace the table with a non-GitLab one and confirm no finding is reported:
DROP TABLE foobar.users; CREATE TABLE foobar.not_a_gitlab_table (id int); -
Clean up:
DROP SCHEMA foobar CASCADE;
