Remove NOT NULL constraint from ci_runner_taggings.tag_id column

NOTE: This issue will only be implemented if we don't implement the trigger solution in #583610

Summary

Remove the NOT NULL constraint from the tag_id column in the ci_runner_taggings table to support the OrgMover workflow.

NOTE: This will only be needed if we don't implement a trigger in #583610

Background

As discussed in #470872 (comment 2946286692):

The tag_id column needs to be nullable so it can be nullified upon organization migration. When OrgMover moves data between cells:

  1. The tag_id will not be migrated (nullified)
  2. The tag_id will be reconstructed on the target cell from the name column to deduplicate against the cell-local tags table
  3. The tag_name column serves as the source of truth for tag data, while tag_id is an acceleration/deduplication field

This aligns with the design outlined in #470872 (comment 2382060671):

We add ci_runner_taggings with name and tag_id... When OrgMoving we do not migrate tag_id, this will be reconstructed later to deduplicate cell-local.

Implementation

  1. Create a migration to remove the NOT NULL constraint from ci_runner_taggings.tag_id
  2. Update any application code that assumes tag_id is always present
  3. Ensure the reconstruction logic can handle null tag_id values and populate them from the tag_name column
Edited by Pedro Pombeiro