Refactor packages versions to use a package class
What does this MR do and why?
Considering the major change related to the decomposition of packages
table, the Packages::Package#versions method won't be able to rely on STI column anymore.
So, we replace the package_type filter with the correct package class.
References
Foundation: Prepare application code to read fr... (#548761 - closed)
Screenshots or screen recordings
No.
How to set up and validate locally
REST API
-
Enable the feature flag
Feature.enable(:packages_refactor_versions) -
Create a package with a couple of versions.
def fixture_file_upload(*args, **kwargs) Rack::Test::UploadedFile.new(*args, **kwargs) end p = FactoryBot.create(:npm_package, version: '1.0.0') FactoryBot.create(:npm_package, version: '2.0.0', name: p.name, project: p.project) FactoryBot.create(:npm_package, version: '3.0.0', name: p.name, project: p.project) FactoryBot.create(:npm_package, version: '4.0.0', name: p.name, project: p.project) -
Create HTTP request to fetch the package's details docs.
$ curl --header "PRIVATE-TOKEN: <your_access_token>" "http://gdk.test:3000/api/v4/projects/{p.project_id}/packages/#{p.id}"Verify the
versionsfield. It should contain the data of other versions.
GraphQL API
-
Execute the steps 1. and 2. from the REST API section if you haven't already.
-
Visit graphql explorer and execute the next query http://gdk.test:3000/-/graphql-explorer
query { package(id: "gid://gitlab/Packages::Package/{p.id}"){ id name versions { edges { node { id version } } } } }Verify the
versionsattribute. It should contain the data of other versions.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #548761 (closed)