Update Maven cache entry composite PK to use rails native support
What does this MR do and why?
In rails 7.1, the composite primary key support was added. In this MR, we update the VirtualRegistries::Packages::Maven::Cache::Entry model to utilize this support.
The database table already has the correct definition, so it's merely a backend change.
References
- Set up partitioning for maven virtual registry ... (!174985 - merged) • David Fernandez • 17.8
- https://guides.rubyonrails.org/active_record_composite_primary_keys.html
Screenshots or screen recordings
N/A
How to set up and validate locally
In rails console:
# stub file upload
def fixture_file_upload(*args, **kwargs)
Rack::Test::UploadedFile.new(*args, **kwargs)
end
# create a new cache entry
ce = FactoryBot.create(:virtual_registries_packages_maven_cache_entry)
# reload the entry and make sure the SQL query uses the correct composite PK
ce.reload
=> VirtualRegistries::Packages::Maven::Cache::Entry Load (1.6ms) SELECT "virtual_registries_packages_maven_cache_entries".* FROM "virtual_registries_packages_maven_cache_entries" WHERE "virtual_registries_packages_maven_cache_entries"."upstream_id" = XXX AND "virtual_registries_packages_maven_cache_entries"."relative_path" = '/foo/bar/test.txt' AND "virtual_registries_packages_maven_cache_entries"."status" = 2 LIMIT 1;
# return the array of the composite primary key column values
ce.id
=> [78, "/foo/bar/test.txt", "default"]
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 #538653 (closed)
Edited by Moaz Khalifa