`deployments.deployable_type` should be `Ci::Build` instead of `CommitStatus`
Problem
Our Deployment
model has deployable
association which represents the source of the deployment. Currently, it only supports Ci::Build
class (a pipeline job executable by runners) as a deployable
, however, we're persisting CommitStatus
into deployable_type
, which is the superclass of Ci::Build
.
This is problematic from data integrity perspective that Deployment
class could mistakenly lookup the other subclass such as Ci::Bridge
, Ci::Processable
or GenericCommitStatus
, that likely result in a critical incident.
Also, in the Multi-project Deployment Pipelines context, we likely add more deployable_type
, such as Ci::Bridge
. So we need to differentiate if the deployment is associated with either Ci::Build
or Ci::Bridge
.
Verifying in SaaS
All rows are CommitStatus
. https://gitlab.slack.com/archives/CLJMDRD8C/p1664852575499879?thread_ts=1664851967.624229&cid=CLJMDRD8C
Proposal
- Backfill
deployments.deployable_type
toCi::Build
wheredeployable_type IS NOT NULL
. - Refactor
deployable_type: 'CommitStatus'
todeployable_type: 'Ci::Build'
e.g. https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/models/deployment.rb#L203 - Fix
Deployments::CreateForBuildService
orSeed::Deployment
to setCi::Build
to thedeployments.deployable_type
.