Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.

Commit 06b8cac

Browse files
committed
[BI-2304] - used zero-indexing in migration
1 parent 0c6952b commit 06b8cac

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/resources/db/migration/V002.001__update_list_positions.sql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ BEGIN
2323
FROM
2424
(
2525
SELECT
26-
row_number() OVER (PARTITION BY li.list_id ORDER BY (g.additional_info->'listEntryNumbers'->>xr.external_reference_id)::int) AS position,
26+
-- Subtract 1 from row_number to get zero indexing.
27+
row_number() OVER (PARTITION BY li.list_id ORDER BY (g.additional_info->'listEntryNumbers'->>xr.external_reference_id)::int) - 1 AS position,
2728
li.id AS list_item_id
2829
FROM
2930
list_item li
@@ -48,7 +49,8 @@ BEGIN
4849
FROM
4950
(
5051
SELECT
51-
row_number() OVER (PARTITION BY li.list_id) AS position,
52+
-- Subtract 1 from row_number to get zero indexing.
53+
row_number() OVER (PARTITION BY li.list_id) - 1 AS position,
5254
li.id AS list_item_id
5355
FROM
5456
list_item li

0 commit comments

Comments
 (0)