Reset group_push_rules primary key sequence

What does this MR do and why?

Resets the group_push_rules_id_seq sequence to MAX(id) + 1000 via a post-deployment migration.

The BackfillGroupPushRulesFromPushRulesWithIds migration (!199456 (merged)) and the sync_namespace_to_group_push_rules trigger insert rows with explicit id values copied from push_rules.id. This does not advance group_push_rules_id_seq, so new INSERTs via PushRules::CreateOrUpdateService produce IDs that collide with existing rows, raising PG::UniqueViolation.

This is particularly impactful on smaller instances (GitLab Dedicated) where push_rules.id values are low and the sequence catches up quickly. On GitLab.com the gap is large enough that it hasn't triggered yet, but it's a latent bug.

Contributes to #588689 (closed)

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist.

How to set up and validate locally

-- Before migration: check the gap
SELECT
  last_value AS current_sequence_value,
  (SELECT MAX(id) FROM group_push_rules) AS max_id
FROM group_push_rules_id_seq;

-- Run migration
-- After migration: verify sequence is ahead of MAX(id)
SELECT
  last_value AS current_sequence_value,
  (SELECT MAX(id) FROM group_push_rules) AS max_id
FROM group_push_rules_id_seq;

Merge request reports

Loading