Skip to content

Resolve "Schema validation - Refactor classes under `SchemaValidation`"

Diogo Frazão requested to merge 345614-implement-index-schema-validation-4 into master

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

  1. Open rails console
  2. Execute:
database = Gitlab::Database::SchemaValidation::Database.new(ActiveRecord::Base.connection)
  1. Execute:
structure_sql = Gitlab::Database::SchemaValidation::StructureSql.new('spec/fixtures/structure.sql')
  1. 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.

Related to #345614 (closed)

Edited by Diogo Frazão

Merge request reports

Loading