Add FK to ci_pending_builds
Ref: #382033 (closed)
What does this MR do and why?
This MR creates the following migrations to redefine our FK to include the partition_id
in order to partition ci_builds
.
It takes care of the following model.
Ci::PendingBuild
And follow a simple strategy using only post migrations as this reference ci_builds a high-traffic table:
- Creates an index
- Creates the FK
This is a similar approach we implemented in !107476 (merged).
Database
gitlabhq_dblab=# select count(*) from ci_pending_builds where partition_id = 101;
count
-------
0
(1 row)
As explained in #387621 (closed) we need to include a new statement when defining our FK: ON UPDATE CASCADE
.
This way we will only update partition_id
on ci_builds
and it will cascade to all other referenced resources and fix our invalid records in production.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.