Skip to content

Add new "Generic" package type

Krasimir Angelov requested to merge 235490-generic-packages/generic-type into master

What does this MR do?

This MR introduces new "generic" package type. It adds new enum for Packages::Package for the generic package type.

It also adds validation for version and adds new partial unique DB index on project_id, name, version when package_type is generic.

Related to #235492 (closed).

Migrations

Up

$ bundle exec rails db:migrate:up VERSION=20200821034419
== 20200821034419 AddUniqueIndexForGenericPackages: migrating =================
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:packages_packages, [:project_id, :name, :version], {:unique=>true, :where=>"package_type = 7", :name=>"index_packages_on_project_id_name_version_unique_when_generic", :algorithm=>:concurrently})
   -> 0.0044s
== 20200821034419 AddUniqueIndexForGenericPackages: migrated (0.0045s) ========

$ bundle exec rails db:migrate:up VERSION=20200824045812
== 20200824045812 AddGenericPackageMaxFileSizeToPlanLimits: migrating =========
-- add_column(:plan_limits, :generic_packages_max_file_size, :bigint, {:default=>5368709120, :null=>false})
   -> 0.0050s
== 20200824045812 AddGenericPackageMaxFileSizeToPlanLimits: migrated (0.0051s)  

Down

$ bundle exec rails db:migrate:down VERSION=20200824045812
== 20200824045812 AddGenericPackageMaxFileSizeToPlanLimits: reverting =========
-- remove_column(:plan_limits, :generic_packages_max_file_size, :bigint, {:default=>5368709120, :null=>false})
   -> 0.0028s
== 20200824045812 AddGenericPackageMaxFileSizeToPlanLimits: reverted (0.0065s) 

$ bundle exec rails db:migrate:down VERSION=20200821034419
== 20200821034419 AddUniqueIndexForGenericPackages: reverting =================
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:packages_packages, "index_packages_on_project_id_name_version_unique_when_generic", {:algorithm=>:concurrently})
   -> 0.0044s
== 20200821034419 AddUniqueIndexForGenericPackages: reverted (0.0046s) ========

Index Creation

exec CREATE UNIQUE INDEX CONCURRENTLY index_packages_on_project_id_name_version_unique_when_generic ON public.packages_packages USING btree (project_id, name, version) WHERE (package_type = 7);

The query has been executed. Duration: 522.000 ms 

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Krasimir Angelov

Merge request reports