Convert ci_build_needs.build_id to bigint - Step 1: Add new columns and sync data
The ci_build_needs
table is one of the CI tables that reference ci_builds, which we want to convert as it's Primary Key is at risk of overflowing.
The first step to address the problem is to create a new column of type bigint
, load all the data by using background jobs from the current build_id
column to it and keep them in sync with a trigger.
The overall process for the ci_build_needs
table will be as follows:
- Create a new column
ci_build_needs.build_id_convert_to_bigint
for the Foreign Key that referencesci_builds
, withbigint NOT NULL DEFAULT 0
- Install sync triggers to keep the new columns updated while new records are inserted or existing ones are updated or deleted.
- Start background jobs that will batch through the whole table and copy the
build_id
values to the new column.
We'll follow with a cleanup migration in the next milestone than the one that the aforementioned migrations are deployed, which will add the necessary indexes, swap the PK (and its sequence) and the FKs and finally drop the old columns.
Edited by Yannis Roussos