Add DuplicateDefaultTrackedContextsCheck consistency check

What does this MR do and why?

Adds DuplicateDefaultTrackedContextsCheck - a consistency check that detects and collapses duplicate default tracked contexts per project.

Problem

Projects can end up with multiple security_project_tracked_contexts records where is_default = true. This causes issues with the VAC (Vulnerabilities Across Contexts) feature.

Solution

When duplicates are found, the check:

  1. Selects the context matching the project's actual default_branch as the survivor
  2. If no match, uses the oldest context and updates its context_name
  3. Updates all references in related tables
  4. Deletes the duplicate context records

Queries for DB Review

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist.

Edited by Rushik Subba

Merge request reports

Loading
Loading