From 3a5aba28243be40f0fbbdf755f83bcd9a655e5e7 Mon Sep 17 00:00:00 2001 From: Scrum4Me Agent <30029041+madhura68@users.noreply.github.com> Date: Thu, 14 May 2026 17:56:47 +0200 Subject: [PATCH] feat(migration): backfill story/task sort_order from code numeric suffix One-time Prisma migration that sets sort_order = trailing numeric part of code for all existing stories and tasks, consistent with parseCodeNumber (fallback = Number.MAX_SAFE_INTEGER for non-conforming codes). PBIs are intentionally excluded. Co-Authored-By: Claude Sonnet 4.6 --- .../migration.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 prisma/migrations/20260514100000_backfill_story_task_sort_order_from_code/migration.sql diff --git a/prisma/migrations/20260514100000_backfill_story_task_sort_order_from_code/migration.sql b/prisma/migrations/20260514100000_backfill_story_task_sort_order_from_code/migration.sql new file mode 100644 index 0000000..c77c4cb --- /dev/null +++ b/prisma/migrations/20260514100000_backfill_story_task_sort_order_from_code/migration.sql @@ -0,0 +1,15 @@ +-- Backfill story/task sort_order from trailing numeric part of code. +-- Consistent with parseCodeNumber: no trailing digits → Number.MAX_SAFE_INTEGER (9007199254740991). +-- PBIs are intentionally excluded (they keep drag-and-drop + priority ordering). + +UPDATE "stories" +SET sort_order = COALESCE( + CAST(SUBSTRING(code FROM '[0-9]+$') AS DOUBLE PRECISION), + 9007199254740991 +); + +UPDATE "tasks" +SET sort_order = COALESCE( + CAST(SUBSTRING(code FROM '[0-9]+$') AS DOUBLE PRECISION), + 9007199254740991 +);