Skip to content

Prepare to convert primary type for ci_build_needs table

Andreas Brandl requested to merge ab/pk-conversion-cibuilds-satellites into master

What does this MR do?

This change adds database migrations to prepare ci_build_needs for a type change of foreign key build_id to ci_builds (int -> bigint).

  1. Add column ci_build_needs.build_id_convert_to_bigint
  2. Add triggers to keep this column in sync with build_id
  3. Ignore the added column on the Ci::BuildNeed model
  4. Work around a limitation of accepts_nested_attributes_for which doesn't exclude ignored columns

Without (4), this causes problems with the "retry builds" feature. See spec failures in https://gitlab.com/gitlab-org/gitlab/-/jobs/1183797636.

From commit message:

In Ci::Processable, we define `accepts_nested_attributes_for :needs`.
Unfortunately, this does not exclude columns ignored on `Ci::BuildNeed`.

There is a database trigger in place, that always keeps the
`build_id_convert_to_bigint` column in sync with `build_id`. Hence, a
copy of a build (e.g. when retrying) will have a different value for
this column compared to before.

This should be a temporary workaround while we maintain that column
through database trigger.

#328044 (closed)

Does this MR meet the acceptance criteria?

Conformity

Edited by Kamil Trzciński

Merge request reports