diff --git a/db/migrate/20210614143954_add_unique_index_for_helm_packages.rb b/db/migrate/20210614143954_add_unique_index_for_helm_packages.rb new file mode 100644 index 0000000000000000000000000000000000000000..e6b7ba7616d7a95e7e71e40a86f8fe7026eb0705 --- /dev/null +++ b/db/migrate/20210614143954_add_unique_index_for_helm_packages.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddUniqueIndexForHelmPackages < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + INDEX_NAME = 'index_packages_on_project_id_name_version_unique_when_helm' + PACKAGE_TYPE_HELM = 11 + + disable_ddl_transaction! + + def up + add_concurrent_index :packages_packages, [:project_id, :name, :version], unique: true, where: "package_type = #{PACKAGE_TYPE_HELM}", name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :packages_packages, INDEX_NAME + end +end diff --git a/db/schema_migrations/20210614143954 b/db/schema_migrations/20210614143954 new file mode 100644 index 0000000000000000000000000000000000000000..7fd3ce9b49eeeabe2fdae1eede47177450727615 --- /dev/null +++ b/db/schema_migrations/20210614143954 @@ -0,0 +1 @@ +b958d65f1b3b43d7bcd2a703489132ba9a2ba1e0374d45533399355ce6be9365 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index fa72d72cb9da5177879b25694fabd5040a71c741..6de556b602f7bdb8bc4af3bd17ebaaca2c18588e 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -24117,6 +24117,8 @@ CREATE UNIQUE INDEX index_packages_on_project_id_name_version_unique_when_generi 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);