Add NOT VALID NOT NULL constraint on notes sharding key

What does this MR do and why?

There are still offending records in the table, so we will validate the constraint after the backfill. We still need to make sure no new offending records are created

The constraint was already introduced in .com as it caused a few errors affecting a small portion of users https://new-sentry.gitlab.net/organizations/gitlab/issues/?alert_rule_id=52&alert_type=issue&environment=gprd&notification_uuid=667e632b-7227-49a8-9001-0c797ade15bc&project=3&query=check_82f260979e&referrer=issue-list&statsPeriod=14d

The original migration was changed into a no-op in !205072 (merged) so the migration is not released for self hosted in 18.4. That MR did make it into the stable branch.

Then, a fix was merged in Set sharding key when missing on note markdown ... (!205125 - merged) and already deployed to production. So the constraint was never dropped in .com.

This MR reintroduces the constraint, but it won't fail in .com because the migration helper checks if the constraint already exists before creating it.

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 #444222 (closed)

Merge request reports

Loading