Welcome to mirror list, hosted at ThFree Co, Russian Federation.

update_ci_pipeline_artifacts_unknown_locked_status.rb « background_migration « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 77b4a9ab7e45f62d0ddae8b34c19773f6c9ba8d3 (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
25
26
# 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
      feature_category :database

      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