Schedule index removal for ci_builds_metadata

Ref: #373239 (closed)

What does this MR do?

This MR schedules an index removal for index_ci_builds_metadata_on_build_id.

Why are we doing this?

Following up !97924 (merged) where we introduced our new index unique index including the partition key.

Indexes:
-   "index_ci_builds_metadata_on_build_id" UNIQUE, btree (build_id)
    "index_ci_builds_metadata_on_build_id_partition_id_unique" UNIQUE, btree (build_id, partition_id)

This MR removes our previous index in order to be able to partition ci_build_metadata with our zero partition helper as all unique constraints must include the partition key.

How to set up and validate locally

  1. Verify the index does exist
gitlabhq_development=# \di+ index_ci_builds_metadata_on_build_id;
                                   List of relations
Schema |             Name             | Type  |  Owner   |   Table   | Size  | Description
--------+------------------------------+-------+----------+-----------+-------+-------------
public | index_ci_builds_metadata_on_build_id | index | morefice | security_findings | 76 GB |
(1 row)
  1. Enable feature flag
Feature.enable(:database_reindexing)
  1. Run migration with bundle exec rails db:migrate
  2. Run bundle exec rails gitlab:db:reindex so the index is destroyed asynchronously
  3. Verify the index no longer exist
gitlabhq_development=# \di+ index_ci_builds_metadata_on_build_id;
Did not find any relation named "index_ci_builds_metadata_on_build_id".

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Max Orefice

Merge request reports

Loading