Add new "Generic" package type
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
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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