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 <noreply@anthropic.com>
This commit is contained in:
Scrum4Me Agent 2026-05-14 17:56:47 +02:00
parent 631d5e679c
commit 3a5aba2824

View file

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