Loading
Draft: Add sharding key trigger and backfill for bulk_import_export_batches.organization_id
What does this MR do and why?
Part 2 of 2: Trigger + batched background migration to backfill bulk_import_export_batches.organization_id
Second step toward an organization_id sharding key on bulk_import_export_batches for issue #603592 (closed), mirroring merged !241089 (merged) (parent table, #600457 (closed)):
- Installs a sharding key assignment trigger via the shared
install_sharding_key_assignment_triggerhelper (single-hop: copiesorganization_idfrom the relatedbulk_import_exportsrow viaexport_id) - Queues the
BackfillBulkImportExportBatchesOrganizationIdbatched background migration (batch_size: 1000,sub_batch_size: 100,gitlab_main_org) - The BBM job touches
updated_aton rows withorganization_id IS NULLand lets the trigger derive the value (same approach as the parent job)
NOT NULL constraint, FK validation, and the sharding_key: db/docs switch are deliberately out of scope; they land in the finalize step, #603593 (closed).
Note for reviewers: this is a stacked MR. It is based on and targets the branch of Part 1: !243557 (closed). Please review that one first.
Migration details
db/post_migrate/20260702130000_add_sharding_key_trigger_on_bulk_import_export_batches.rb
db/post_migrate/20260702130001_queue_backfill_bulk_import_export_batches_organization_id.rbMR acceptance checklist
- Migrations tested up and down locally
- Database review
References
- Issue #603592 (closed) (parent #600457 (closed) done via !241088 (merged) / !241089 (merged); finalize is #603593 (closed) and out of scope here)