diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2024-01-11 15:09:29 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2024-01-11 15:09:29 +0300 |
commit | 97feef1f73fd0a3237d1a2aef4e977e7e27ecace (patch) | |
tree | 4153af3602f242ed1a138fe70bd843a2564dab19 /lib/gitlab/background_migration/backfill_partition_id_ci_pipeline_artifact.rb | |
parent | 6f5be4b446db2f17fc0307c4fce8ae285b35d89a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/background_migration/backfill_partition_id_ci_pipeline_artifact.rb')
-rw-r--r-- | lib/gitlab/background_migration/backfill_partition_id_ci_pipeline_artifact.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/gitlab/background_migration/backfill_partition_id_ci_pipeline_artifact.rb b/lib/gitlab/background_migration/backfill_partition_id_ci_pipeline_artifact.rb new file mode 100644 index 00000000000..73996ce4460 --- /dev/null +++ b/lib/gitlab/background_migration/backfill_partition_id_ci_pipeline_artifact.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Gitlab + module BackgroundMigration + class BackfillPartitionIdCiPipelineArtifact < BatchedMigrationJob + operation_name :update_all + feature_category :continuous_integration + + def perform + return unless uses_multiple_partitions? + + each_sub_batch do |sub_batch| + sub_batch + .where('ci_pipeline_artifacts.pipeline_id = ci_pipelines.id') + .update_all('partition_id = ci_pipelines.partition_id FROM ci_pipelines') + end + end + + private + + def uses_multiple_partitions? + !!connection.select_value(<<~SQL) + SELECT true FROM p_ci_builds WHERE partition_id = 101 LIMIT 1 + SQL + end + end + end +end |