Loading
Create partitioned table p_ci_build_needs
What does this MR do and why?
This MR converts the ci_build_needs table to a list-partitioned table as part of the CI data partitioning initiative. It creates the parent partitioned table p_ci_build_needs and attaches the existing ci_build_needs table as its first partition (covering partition_id values 100–111).
Key changes:
- Model update: Sets
sequence_nameonCi::BuildNeedto explicitly useci_build_needs_id_seq, ensuring correct sequence ownership after the parent table takes over. - Post-migration: Sync constraint (
20260326000459): Validates the existingpartitioning_constraintcheck constraint onci_build_needsbefore the conversion. - Post-migration: Drop old unique index (
20260326000462): Removes the legacyindex_ci_build_needs_on_build_id_and_nameindex (non-partition-aware) fromci_build_needs, replaced by the partition-awareindex_ci_build_needs_on_build_id_and_name_partitioning. - Post-migration: Convert to list partition (
20260326000464): Callsconvert_table_to_first_list_partitionto createp_ci_build_needsas the partitioned parent and attachci_build_needsas the first partition for values 100–111. - Schema updates: Reflects the new parent table
p_ci_build_needswithPARTITION BY LIST (partition_id), updated primary key, indexes, and foreign key constraints. - Bump sequences fix: Adds
.uniqtosequences_by_gitlab_schemato avoid duplicate sequence entries that could arise when both the parent and child tables reference the same sequence. - Spec/sharding key updates: Registers
p_ci_build_needsin the schema spec and sharding key spec, noting that the LFK is already covered via cascade delete fromp_ci_builds. - DB docs: Adds
db/docs/p_ci_build_needs.ymldocumenting the new table with its sharding key, feature category, and schema.
Changelog: added
References
Related to #583639 (closed)
Screenshots or screen recordings
N/A – database migration only
How to set up and validate locally
- Run the post-migrations in order:
bundle exec rails db:migrate:up VERSION=20260326000459 bundle exec rails db:migrate:up VERSION=20260326000462 bundle exec rails db:migrate:up VERSION=20260326000464 - Verify the parent table exists and the partition is attached:
\d+ p_ci_build_needs - Confirm
ci_build_needsis listed as a partition ofp_ci_build_needsfor values100–111. - Run rollback to verify
downmigrations work correctly.
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 Marius Bobin