Commit b22a725a authored by Michael Kozono's avatar Michael Kozono

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
parents b0854042 0f5b7356
......@@ -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
)
......
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment