Skip to content

Delete orphaned packages dependencies

What does this MR do and why?

MR !20549 (merged) added two tables: packages_dependencies and packages_dependency_links. When a package is deleted, packages_dependency_links rows are properly deleted but rows in packages_dependencies are kept and they can become orphans. This MR aims to clean up those orphaned packages_dependencies records in a batched background migration.

A follow-up MR should be merged after we deploy this one to make sure we have a cron job that deletes the orphaned records daily.

How to set up and validate locally

  1. In Rails console, create a bunch of orphaned packages_dependencies records: FactoryBot.create_list(:packages_dependency, 100)
  2. Make sure sidekiq is up & running locally.
  3. Run the migration rails db:migrate:up:main VERSION=20230303105806
  4. The orphaned records should be deleted successfully.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Database analysis

!113556 (comment 1300749110)

Related to #38266 (closed)

Edited by Moaz Khalifa

Merge request reports