diff options
Diffstat (limited to 'db/migrate/20220919225631_add_index_packages_packages_on_project_id_and_lower_version_to_packages.rb')
-rw-r--r-- | db/migrate/20220919225631_add_index_packages_packages_on_project_id_and_lower_version_to_packages.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/db/migrate/20220919225631_add_index_packages_packages_on_project_id_and_lower_version_to_packages.rb b/db/migrate/20220919225631_add_index_packages_packages_on_project_id_and_lower_version_to_packages.rb new file mode 100644 index 00000000000..23b58522639 --- /dev/null +++ b/db/migrate/20220919225631_add_index_packages_packages_on_project_id_and_lower_version_to_packages.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class AddIndexPackagesPackagesOnProjectIdAndLowerVersionToPackages < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + INDEX_NAME = 'index_packages_packages_on_project_id_and_lower_version' + NUGET_PACKAGE_TYPE = 4 + + def up + add_concurrent_index( + :packages_packages, + 'project_id, LOWER(version)', + name: INDEX_NAME, + where: "package_type = #{NUGET_PACKAGE_TYPE}" + ) + end + + def down + remove_concurrent_index_by_name(:packages_packages, INDEX_NAME) + end +end |