Commit e9bb6166 authored by Adam Hegyi's avatar Adam Hegyi

Fix index definition

Add `id` to the index to support the tie breaker ordering.
parent 335222ba
......@@ -9,12 +9,12 @@ class ChangeIndexMrMetricsTargetProjectId < ActiveRecord::Migration[6.0]
NULLS_LAST_INDEX_NAME = 'index_mr_metrics_on_target_project_id_merged_at_nulls_last'
def up
add_concurrent_index :merge_request_metrics, [:target_project_id, :merged_at], order: { merged_at: 'DESC NULLS LAST' }, name: NULLS_LAST_INDEX_NAME
add_concurrent_index :merge_request_metrics, [:target_project_id, :merged_at, :id], order: { merged_at: 'DESC NULLS LAST', id: 'DESC' }, name: NULLS_LAST_INDEX_NAME
remove_concurrent_index_by_name(:merge_request_metrics, INDEX_NAME)
end
def down
add_concurrent_index :merge_request_metrics, [:target_project_id, :created_at, :merged_at], name: INDEX_NAME
add_concurrent_index :merge_request_metrics, [:target_project_id, :merged_at], name: INDEX_NAME
remove_concurrent_index_by_name(:merge_request_metrics, NULLS_LAST_INDEX_NAME)
end
end
......@@ -21192,7 +21192,7 @@ CREATE UNIQUE INDEX index_mr_blocks_on_blocking_and_blocked_mr_ids ON merge_requ
CREATE UNIQUE INDEX index_mr_context_commits_on_merge_request_id_and_sha ON merge_request_context_commits USING btree (merge_request_id, sha);
CREATE INDEX index_mr_metrics_on_target_project_id_merged_at_nulls_last ON merge_request_metrics USING btree (target_project_id, merged_at DESC NULLS LAST);
CREATE INDEX index_mr_metrics_on_target_project_id_merged_at_nulls_last ON merge_request_metrics USING btree (target_project_id, merged_at DESC NULLS LAST, id DESC);
CREATE UNIQUE INDEX index_namespace_aggregation_schedules_on_namespace_id ON namespace_aggregation_schedules USING btree (namespace_id);
......
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