[go: up one dir, main page]

Skip to content

Make Ci::JobDefinition model insert only

Problem

With the idea of adding p_ci_job_definitions table we need to ensure that the model Ci::JobDefinition is insert-only and can never be updated once created. We have to protect the crucial invariant that the job definition is immutable because it will be shared across multiple jobs. Modifying it to suit a single job configuration will break other job configurations.

The only exception might be to allow updates in specs but we should try to implement an helper (e.g. unsafe_update_job_definition) that is only available in specs rather than using update! directly.

Implementation notes

Check the PoC !193948 (closed) for how the JobDefinition (JobPrototype in the PoC) is going to be implemented.

We could turn every Ci::JobDefinition record as readonly! in the after_initialize callback so we ensure they don't get updated. Obviously, a update_column would still bypass it but it should be already discouraged.

Regarding specs, see #519972 (comment 2740407940).

Edited by 🤖 GitLab Bot 🤖