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 +);