Add and backfill a sharding_key to an existing large table
Similar to #429173 (closed) but we want to work out the details needed for migrating a very large table.
A candidate table might be security_findings
but this table is huge so it may even be too big.
Possible tables
-
security_findings
- Started in !135691 (closed) but blocked by #431134
label_links
resource_label_events
-
merge_request_diffs
- Started in !136800 (merged)
merge_request_diffs.project_id
:
-
MR1 !136800 (merged): - Adds the column in db/migrate
- Adds the application code to write the column
- Adds the invalid not-null constraint in db/post_migrate
- Adds the async index on
project_id
-
MR2: !139726 (merged): (once all old records without project_id have been updated) - Finalize the batched background migration
- Validates the not-null constraint
-
MR3 !137495 (merged): (when the async index creation is finished) - Finalizes the async index creation
- Adds the foreign key invalid
-
MR4 !140410 (merged): - Adds the async validation of the foreign key constraint
-
MR5 !140280 (merged): - Finalizes validating the foreign key constraint
Edited by Tiger Watson