Updates schema validation index query
What does this MR do and why?
Updates schema validation index query to exclude indexes that were created by constraints
How to set up and validate locally
- Switch to
master
git checkout master
- Create some constraints. One
contype x
(EXCLUDE) and the othercontype u
(UNIQUE)
ALTER TABLE ONLY sprints ADD CONSTRAINT constraint_one EXCLUDE USING gist (iterations_cadence_id WITH =, daterange(start_date, due_date, '[]'::text) WITH &&) WHERE ((group_id IS NOT NULL)) DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE ONLY sprints ADD CONSTRAINT constraint_two UNIQUE (iterations_cadence_id, sequence) DEFERRABLE INITIALLY DEFERRED;
- In a rails console session, get the indexes
connection = Gitlab::Database.database_base_models[Gitlab::Database::MAIN_DATABASE_NAME].connection
database = Gitlab::Schema::Validation::Sources::Database.new(connection)
database.fetch_index_by_name('constraint_one')
=> #<Gitlab::Schema::Validation::SchemaObjects::Index:0x000000013d347518
database.fetch_index_by_name('constraint_two')
=> #<Gitlab::Schema::Validation::SchemaObjects::Index:0x000000013d346528
-
Switch to this branch
git checkout 390667-table-constraint-creates-a-new-index
-
In a rails console session,
.fetch_index_by_name
should returnnil
connection = Gitlab::Database.database_base_models[Gitlab::Database::MAIN_DATABASE_NAME].connection
database = Gitlab::Schema::Validation::Sources::Database.new(connection)
database.fetch_index_by_name('constraint_one')
=> nil
database.fetch_index_by_name('constraint_two')
=> nil
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 #390667 (closed)
Edited by Leonardo da Rosa