diff --git a/db/post_migrate/20240108181808_remove_package_registry_duplicated_indexes.rb b/db/post_migrate/20240108181808_remove_package_registry_duplicated_indexes.rb new file mode 100644 index 0000000000000000000000000000000000000000..96380b94d5069fddacdbd5fc7ed8a48ebf572025 --- /dev/null +++ b/db/post_migrate/20240108181808_remove_package_registry_duplicated_indexes.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +class RemovePackageRegistryDuplicatedIndexes < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + milestone '16.8' + + DUPLICATED_INDEXES = [ + { + name: :index_packages_debian_group_distributions_on_group_id, + table: :packages_debian_group_distributions, + column: :group_id + }, + { + name: :index_packages_debian_project_distributions_on_project_id, + table: :packages_debian_project_distributions, + column: :project_id + }, + { + name: :index_packages_tags_on_package_id, + table: :packages_tags, + column: :package_id + } + ] + + def up + DUPLICATED_INDEXES.each do |index| + remove_concurrent_index_by_name(index[:table], index[:name]) + end + end + + def down + DUPLICATED_INDEXES.each do |index| + add_concurrent_index(index[:table], index[:column], name: index[:name]) + end + end +end diff --git a/db/schema_migrations/20240108181808 b/db/schema_migrations/20240108181808 new file mode 100644 index 0000000000000000000000000000000000000000..542a576fdf1b9294457d21675f32a6ce7b5907fb --- /dev/null +++ b/db/schema_migrations/20240108181808 @@ -0,0 +1 @@ +688603d4b31b17d1eeb133e293876aae77ab68b80f656fb9b902ca38d4c7beed \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 950792e9d5207a8f3094864009888c0a45957079..7218399453c71a598fc38064b03f5822e4920e34 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -34001,14 +34001,10 @@ CREATE INDEX index_packages_debian_group_component_files_on_component_id ON pack CREATE INDEX index_packages_debian_group_distributions_on_creator_id ON packages_debian_group_distributions USING btree (creator_id); -CREATE INDEX index_packages_debian_group_distributions_on_group_id ON packages_debian_group_distributions USING btree (group_id); - CREATE INDEX index_packages_debian_project_component_files_on_component_id ON packages_debian_project_component_files USING btree (component_id); CREATE INDEX index_packages_debian_project_distributions_on_creator_id ON packages_debian_project_distributions USING btree (creator_id); -CREATE INDEX index_packages_debian_project_distributions_on_project_id ON packages_debian_project_distributions USING btree (project_id); - CREATE INDEX index_packages_debian_publications_on_distribution_id ON packages_debian_publications USING btree (distribution_id); CREATE UNIQUE INDEX index_packages_debian_publications_on_package_id ON packages_debian_publications USING btree (package_id); @@ -34085,8 +34081,6 @@ CREATE INDEX index_packages_rpm_metadata_on_package_id ON packages_rpm_metadata CREATE INDEX index_packages_rpm_repository_files_on_project_id_and_file_name ON packages_rpm_repository_files USING btree (project_id, file_name); -CREATE INDEX index_packages_tags_on_package_id ON packages_tags USING btree (package_id); - CREATE INDEX index_packages_tags_on_package_id_and_updated_at ON packages_tags USING btree (package_id, updated_at DESC); CREATE INDEX index_packages_tags_on_project_id ON packages_tags USING btree (project_id); diff --git a/spec/support/helpers/database/duplicate_indexes.yml b/spec/support/helpers/database/duplicate_indexes.yml index 87a1e0c2c50abaf3326e4b23aa7f83710c73a78d..acfda313020a791e28d73269e5684d5d086dceda 100644 --- a/spec/support/helpers/database/duplicate_indexes.yml +++ b/spec/support/helpers/database/duplicate_indexes.yml @@ -105,19 +105,6 @@ ml_models: p_ci_runner_machine_builds: index_p_ci_runner_machine_builds_on_runner_machine_id: - index_ci_runner_machine_builds_on_runner_machine_id -packages_debian_group_distributions: - uniq_pkgs_debian_group_distributions_group_id_and_codename: - - index_packages_debian_group_distributions_on_group_id - uniq_pkgs_debian_group_distributions_group_id_and_suite: - - index_packages_debian_group_distributions_on_group_id -packages_debian_project_distributions: - uniq_pkgs_debian_project_distributions_project_id_and_codename: - - index_packages_debian_project_distributions_on_project_id - uniq_pkgs_debian_project_distributions_project_id_and_suite: - - index_packages_debian_project_distributions_on_project_id -packages_tags: - index_packages_tags_on_package_id_and_updated_at: - - index_packages_tags_on_package_id pages_domains: index_pages_domains_on_project_id_and_enabled_until: - index_pages_domains_on_project_id