Resolve "Schema validation - Refactor classes under `SchemaValidation`"
What does this MR do and why?
I am refactoring the classes under SchemaValidation
in this merge request. The behavior of this feature is still the same.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
How to set up and validate locally
- Open rails console
- Execute:
database = Gitlab::Database::SchemaValidation::Database.new(ActiveRecord::Base.connection)
- Execute:
structure_sql = Gitlab::Database::SchemaValidation::StructureSql.new('spec/fixtures/structure.sql')
- Execute:
indexes = Gitlab::Database::SchemaValidation::Indexes.new(structure_sql, database)
Play with the following methods:
-
indexes.missing_indexes
The index is present in the structure file but is not present in the database. -
indexes.extra_indexes
: The index is present in the database but not in the structure file. -
indexes.wrong_indexes
: The index is present in the database and the structure file, but the statements don't match.
Note:
If you wanna try new scenarios, feel free to add new SQL statements to the 'spec/fixtures/structure.sql' file and add new indexes to the database via gdk psql
.
More info: https://www.postgresql.org/docs/current/sql-createindex.html
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #345614 (closed)
Edited by Diogo Frazão