diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-15 08:58:20 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-15 08:58:20 +0000 |
commit | 59c9ff627603da03f6a7c330d57a2c765b3c24a3 (patch) | |
tree | dd8f3a2fbc9564818a77d2d8798fcc464d220e8e /db | |
parent | 30b4659f2c485885324fd8d67fcd92a2939310a3 (diff) | |
download | gitlab-ce-59c9ff627603da03f6a7c330d57a2c765b3c24a3.tar.gz |
Add latest changes from gitlab-org/gitlab@14-7-stable-ee
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20220203091304_fix_unique_packages_index_excluding_pending_destruction_status.rb | 28 | ||||
-rw-r--r-- | db/schema_migrations/20220203091304 | 1 | ||||
-rw-r--r-- | db/structure.sql | 12 |
3 files changed, 35 insertions, 6 deletions
diff --git a/db/migrate/20220203091304_fix_unique_packages_index_excluding_pending_destruction_status.rb b/db/migrate/20220203091304_fix_unique_packages_index_excluding_pending_destruction_status.rb new file mode 100644 index 00000000000..c30d8de23db --- /dev/null +++ b/db/migrate/20220203091304_fix_unique_packages_index_excluding_pending_destruction_status.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +class FixUniquePackagesIndexExcludingPendingDestructionStatus < Gitlab::Database::Migration[1.0] + disable_ddl_transaction! + + GO_UNIQUE_INDEX_NAME = 'index_packages_on_project_id_name_version_unique_when_golang' + GENERIC_UNIQUE_INDEX_NAME = 'index_packages_on_project_id_name_version_unique_when_generic' + HELM_UNIQUE_INDEX_NAME = 'index_packages_on_project_id_name_version_unique_when_helm' + + NEW_GO_UNIQUE_INDEX_NAME = 'idx_packages_on_project_id_name_version_unique_when_golang' + NEW_GENERIC_UNIQUE_INDEX_NAME = 'idx_packages_on_project_id_name_version_unique_when_generic' + NEW_HELM_UNIQUE_INDEX_NAME = 'idx_packages_on_project_id_name_version_unique_when_helm' + + def up + add_concurrent_index :packages_packages, [:project_id, :name, :version], unique: true, name: NEW_GO_UNIQUE_INDEX_NAME, where: 'package_type = 8 AND status != 4' + add_concurrent_index :packages_packages, [:project_id, :name, :version], unique: true, name: NEW_GENERIC_UNIQUE_INDEX_NAME, where: 'package_type = 7 AND status != 4' + add_concurrent_index :packages_packages, [:project_id, :name, :version], unique: true, name: NEW_HELM_UNIQUE_INDEX_NAME, where: 'package_type = 11 AND status != 4' + + remove_concurrent_index_by_name :packages_packages, GO_UNIQUE_INDEX_NAME + remove_concurrent_index_by_name :packages_packages, GENERIC_UNIQUE_INDEX_NAME + remove_concurrent_index_by_name :packages_packages, HELM_UNIQUE_INDEX_NAME + end + + def down + # no-op + # We can't guarantee that the old index can be recreated since it targets a set larger that the new index. + end +end diff --git a/db/schema_migrations/20220203091304 b/db/schema_migrations/20220203091304 new file mode 100644 index 00000000000..847620db3d2 --- /dev/null +++ b/db/schema_migrations/20220203091304 @@ -0,0 +1 @@ +dac90da1a8c5af69610dd103c8db9cd70a395ad5f9addafb554a853d6acd2a6e
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 47e111bf48f..8d0c7b3d693 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -25161,6 +25161,12 @@ CREATE INDEX idx_packages_debian_group_component_files_on_architecture_id ON pac CREATE INDEX idx_packages_debian_project_component_files_on_architecture_id ON packages_debian_project_component_files USING btree (architecture_id); +CREATE UNIQUE INDEX idx_packages_on_project_id_name_version_unique_when_generic ON packages_packages USING btree (project_id, name, version) WHERE ((package_type = 7) AND (status <> 4)); + +CREATE UNIQUE INDEX idx_packages_on_project_id_name_version_unique_when_golang ON packages_packages USING btree (project_id, name, version) WHERE ((package_type = 8) AND (status <> 4)); + +CREATE UNIQUE INDEX idx_packages_on_project_id_name_version_unique_when_helm ON packages_packages USING btree (project_id, name, version) WHERE ((package_type = 11) AND (status <> 4)); + CREATE INDEX idx_packages_packages_on_project_id_name_version_package_type ON packages_packages USING btree (project_id, name, version, package_type); CREATE INDEX idx_pkgs_debian_group_distribution_keys_on_distribution_id ON packages_debian_group_distribution_keys USING btree (distribution_id); @@ -27031,12 +27037,6 @@ CREATE INDEX index_packages_maven_metadata_on_path ON packages_maven_metadata US CREATE INDEX index_packages_nuget_dl_metadata_on_dependency_link_id ON packages_nuget_dependency_link_metadata USING btree (dependency_link_id); -CREATE UNIQUE INDEX index_packages_on_project_id_name_version_unique_when_generic ON packages_packages USING btree (project_id, name, version) WHERE (package_type = 7); - -CREATE UNIQUE INDEX index_packages_on_project_id_name_version_unique_when_golang ON packages_packages USING btree (project_id, name, version) WHERE (package_type = 8); - -CREATE UNIQUE INDEX index_packages_on_project_id_name_version_unique_when_helm ON packages_packages USING btree (project_id, name, version) WHERE (package_type = 11); - CREATE INDEX index_packages_package_file_build_infos_on_package_file_id ON packages_package_file_build_infos USING btree (package_file_id); CREATE INDEX index_packages_package_file_build_infos_on_pipeline_id ON packages_package_file_build_infos USING btree (pipeline_id); |