XS Add sharding key YAML config to ci_stages & p_ci_stages (1 table)

What we need to do

The ci_stages table has a project_id key, but didn't get the designation automatically a few months ago when the Cells team sent out all the initial MRs.

I'm not sure if there's something blocking this having to do with partitioning.

How to do it

  1. Find out if there's any reason we can't add the sharding key designation immediately and have all the automation work.
    1. Yes there's a reason, we'll need to patch invalid records first
  2. Open up https://gitlab.com/gitlab-org/gitlab/-/blob/master/db/docs/ci_stages.yml
  ---
  table_name: ci_stages
  classes:
  - Ci::Stage
  feature_categories:
  - continuous_integration
  description: TODO
  introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/acc22a8422cd1471819510aa375c455b5ea009c5
  milestone: '9.3'
  gitlab_schema: gitlab_ci
+ sharding_key:
+   project_id: projects

Tasks required to complete this issue

  • Remove orphaned stages through post-migration
  • add validation for presence of project_id on stage
  • add not valid not null constraint to pipeline_id
  • validate not null constraint on pipeline_id once added
  • add sharding key to stages
Edited by Vlad Wolanyk