@yorickpeterse We check if build was retried in quite a few places. Currently to know whether the build was retried, we have to load all pipeline builds and see if there is another similar build in the same stage. This means that we have to execute a lot of queries each time we want to show list of builds in the pipeline with appropriate icon next to builds that were retried.
Ci::Pipeline.latest scope that defines most recent builds, excluding retried ones
A build can be retried multiple times, so it is one-to-many relationship, but in most cases we only need to know if build was retried. Simple solution may be adding ci_builds.retried boolean field and build_retried table to track retries, but the latter may not be necessary at this point.