blob: 841837531587273c1e8f43e2e37e9a8c5ff7c348 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# frozen_string_literal: true
module Gitlab
module BackgroundMigration
# The `ci_pipeline_artifacts.locked` column was added in
# https://gitlab.com/gitlab-org/gitlab/-/merge_requests/97194 to
# speed up the finding of expired, pipeline artifacts. By default,
# the value is "unknown" (2), but the correct value should be the
# value of the associated `ci_pipelines.locked` value. This class
# does an UPDATE join to make the values match.
class UpdateCiPipelineArtifactsUnknownLockedStatus < BatchedMigrationJob
def perform
connection.exec_query(<<~SQL)
UPDATE ci_pipeline_artifacts
SET locked = ci_pipelines.locked
FROM ci_pipelines
WHERE ci_pipeline_artifacts.id BETWEEN #{start_id} AND #{end_id}
AND ci_pipeline_artifacts.locked = 2
AND ci_pipelines.id = ci_pipeline_artifacts.pipeline_id;
SQL
end
end
end
end
|