Backfill nil namespace_ids on notes table
While working on adding a NOT NULL constraint to notes.namespaces_id we discovered that 1.4B of the ~1.8B records contained nil values for namespace_id. We had thought that these records existed when we unwound special casing for AbuseReports, but clearly we need to address this before we continue with sharding.
Solution
Perform a batched backfill migration to populate this value. Notes belong to:
| Noteable | namespace reference | Notes |
|---|---|---|
| Merge Request | self.merge_request.project.namespace_id |
|
| Issue | self.issue.namespace_id |
|
| DesignManagement::Design | self.namespace_id |
|
| AlertManagement::Alert | self.project.namespace_id |
|
| Snippet |
|
|
| Commit | self.project.namespace_id |
|
| EE::Epic | self.epic.namespace_id |
|
| EE::Vulnerability | self.vulnerability.project.namespace_id |
Related to #444222 (closed)
Edited by Kerri Miller