Add NOT NULL constraint on label_links.label_id
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
We found that in https://gitlab.com/gitlab-org/gitlab/issues/197300, project imports can produce label_links
with NULL label_id
values. We have about 65,000 entries (out of 28+ million) in this state:
gitlabhq_production=# select count(*) from label_links where label_id IS NULL;
-[ RECORD 1 ]
count | 64845
We seem to have disabled the Rails validation https://gitlab.com/gitlab-org/gitlab/blob/096ab61dd6b6dcb2304f0ba9cd92fa63906be434/app/models/label_link.rb#L10 during import, so it's possible this happens because we didn't properly export/map labels.
In some migration, we should:
- Drop these entries
- Add the NOT NULL constraint
With 28 million rows, we have to be careful this doesn't lock the table too long.
Edited by 🤖 GitLab Bot 🤖