Class: Gitlab::BackgroundMigration::UpdateCiPipelineArtifactsUnknownLockedStatus

Inherits:
BatchedMigrationJob
  • Object
show all
Defined in:
lib/gitlab/background_migration/update_ci_pipeline_artifacts_unknown_locked_status.rb

Overview

The ‘ci_pipeline_artifacts.locked` column was added in 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.

Constant Summary

Constants inherited from BatchedMigrationJob

BatchedMigrationJob::DEFAULT_FEATURE_CATEGORY

Constants included from Database::DynamicModelHelpers

Database::DynamicModelHelpers::BATCH_SIZE

Instance Method Summary collapse

Methods inherited from BatchedMigrationJob

#batch_metrics, feature_category, #filter_batch, generic_instance, #initialize, job_arguments, job_arguments_count, operation_name, scope_to

Methods included from Database::DynamicModelHelpers

#define_batchable_model, #each_batch, #each_batch_range

Constructor Details

This class inherits a constructor from Gitlab::BackgroundMigration::BatchedMigrationJob

Instance Method Details

#performObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/gitlab/background_migration/update_ci_pipeline_artifacts_unknown_locked_status.rb', line 14

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