Loading
Switch cd_* tables to organization_id sharding key
What does this MR do and why?
MR 1 of 4 to implement changes requested in https://gitlab.com/gitlab-org/gitlab/-/work_items/602442
Introduces organization_id as the sharding key on the existing Continuous Deployment tables. This is the first, purely additive step of aligning the cd_* schema with the Rails design — no columns are dropped here.
- organization_id becomes the sharding key
- cd_applications / cd_environments: organization_id becomes the required sharding key (the XOR num_nonnulls(group_id, organization_id) = 1 check is dropped, organization_id gets a NOT NULL check). group_id stays as an optional owner — not touched.
- cd_services, cd_versions, cd_version_sets, cd_version_set_entries, cd_artifact_sources, cd_rollouts, cd_deployments: add organization_id (bigint) + concurrent index + FK → organizations (ON DELETE CASCADE)
- NOT NULL constraint.
group_id demoted, not dropped
On the 7 swap tables, group_id is:
- made nullable (change_column_null … true), and
- ignore_column'd in the model
References
https://gitlab.com/gitlab-org/gitlab/-/work_items/602442
Screenshots or screen recordings
| Before | After |
|---|---|
How to set up and validate locally
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by George Koltsov