Backup and remove orphaned notes
What does this MR do and why?
We've discovered that there were notes
records with NULL
noteable_type
in the production database. There were 1.6k of them, all from 2013/14 by the created_at/updated_at attributes.
A new check constraint (NOT NULL) has been added in an earlier MR. This MR attempts to backup and remove the orphaned records using the batched background migration tooling.
-
Creates a new table
temp_notes_backup
to store the orphaned records. Before removing the orphaned records, we want to make sure they are backed up to guard against inadvertent data loss (https://docs.gitlab.com/ee/development/migration_style_guide.html#reversibility.) -
Creates and queues a background migration that copies the orphaned records from
notes
intotemp_notes_backup
then removes them.
The follow-up issue to track the finalization/cleanup is #443667 (closed).
Query plans: