summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Kozono <mkozono@gmail.com>2019-04-08 20:11:46 +0000
committerMichael Kozono <mkozono@gmail.com>2019-04-08 20:11:46 +0000
commitb22a725a0c8c122515a16beff50a008b46c4462a (patch)
treefdaa9df353506329494f249794f721a65352f298
parentb0854042923e9e8ad6b3f34b29631ffaa127d06e (diff)
parent0f5b735685476ff51b26031e9b74fa8256354868 (diff)
downloadgitlab-ce-b22a725a0c8c122515a16beff50a008b46c4462a.tar.gz
Merge branch 'sh-fix-issue-59985' into 'master'
Fix stage index migration failing in PostgreSQL 10 Closes #59985 See merge request gitlab-org/gitlab-ce!26972
-rw-r--r--lib/gitlab/background_migration/migrate_stage_index.rb4
-rw-r--r--spec/lib/gitlab/background_migration/migrate_stage_index_spec.rb2
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/gitlab/background_migration/migrate_stage_index.rb b/lib/gitlab/background_migration/migrate_stage_index.rb
index f90f35a913d..f921233460d 100644
--- a/lib/gitlab/background_migration/migrate_stage_index.rb
+++ b/lib/gitlab/background_migration/migrate_stage_index.rb
@@ -21,8 +21,8 @@ module Gitlab
AND stage_idx IS NOT NULL
GROUP BY stage_id, stage_idx
), indexes AS (
- SELECT DISTINCT stage_id, last_value(stage_idx)
- OVER (PARTITION BY stage_id ORDER BY freq ASC) AS index
+ SELECT DISTINCT stage_id, first_value(stage_idx)
+ OVER (PARTITION BY stage_id ORDER BY freq DESC) AS index
FROM freqs
)
diff --git a/spec/lib/gitlab/background_migration/migrate_stage_index_spec.rb b/spec/lib/gitlab/background_migration/migrate_stage_index_spec.rb
index f8107dd40b9..4db829b1e7b 100644
--- a/spec/lib/gitlab/background_migration/migrate_stage_index_spec.rb
+++ b/spec/lib/gitlab/background_migration/migrate_stage_index_spec.rb
@@ -30,6 +30,6 @@ describe Gitlab::BackgroundMigration::MigrateStageIndex, :migration, schema: 201
described_class.new.perform(100, 101)
- expect(stages.all.pluck(:position)).to eq [2, 3]
+ expect(stages.all.order(:id).pluck(:position)).to eq [2, 3]
end
end