Add task priority field
Introduce a rank-style priority on tasks, scoped by (organization_id, state). New tasks auto-assign the next priority. Reordering uses the same CTE-based algorithm as trust center references and compliance external URLs. Exposed through GraphQL, MCP, and the PRIORITY order field. Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
19
pkg/coredata/migrations/20260326T160000Z.sql
Normal file
19
pkg/coredata/migrations/20260326T160000Z.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
ALTER TABLE tasks ADD COLUMN priority INTEGER;
|
||||
|
||||
WITH ranked_tasks AS (
|
||||
SELECT
|
||||
id,
|
||||
ROW_NUMBER() OVER (PARTITION BY organization_id, state ORDER BY created_at DESC, id DESC) AS rn
|
||||
FROM tasks
|
||||
)
|
||||
UPDATE tasks t
|
||||
SET priority = rt.rn
|
||||
FROM ranked_tasks rt
|
||||
WHERE t.id = rt.id;
|
||||
|
||||
ALTER TABLE tasks ALTER COLUMN priority SET NOT NULL;
|
||||
|
||||
ALTER TABLE tasks
|
||||
ADD CONSTRAINT tasks_organization_id_state_priority_key
|
||||
UNIQUE (organization_id, state, priority)
|
||||
DEFERRABLE INITIALLY DEFERRED;
|
||||
Reference in New Issue
Block a user