Skip to content

Re-point referenced FKs to p_ci_job_artifacts

Problem

The tables that reference the initial partition must be updated to point to the parent table now. Without this change, the records from those tables will not be able to locate the rows in the next partitions because they will look for them in the initial partition.

Solution

Update the following FKs to the parent table (p_ci_job_artifacts)

Referenced by:
    TABLE "ci_build_trace_metadata" CONSTRAINT "fk_21d25cac1a_p" FOREIGN KEY (partition_id, trace_artifact_id) REFERENCES ci_job_artifacts(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE
    TABLE "ci_job_artifact_states" CONSTRAINT "fk_rails_80a9cba3b2_p" FOREIGN KEY (partition_id, job_artifact_id) REFERENCES ci_job_artifacts(partition_id, id) ON UPDATE CASCADE ON DELETE CASCADE

https://docs.gitlab.com/ee/development/database/partitioning/list.html#step-7---re-point-foreign-keys-to-parent-table

Edited by Max Orefice