Add per-project card statuses and a kanban board
Statuses
- Migration 006: card_statuses table (project-scoped) and cards.status_id, a
nullable FK with ON DELETE SET NULL. Every new project is seeded with
"To do" / "Doing" / "Done"; GET /api/projects/{id}/statuses lists them.
- New cards have no status -- they sit in an "inbox" until moved.
Project view
- Full-width and tabbed: "All tasks" (a flat list, sorted by name
case-insensitively) and "Kanban" (Inbox plus one column per status).
- Drag a card within or between columns to reorder / restatus; the Inbox
column has its own name + Add form.
Ordering
- Migration 007: `position` is now a dense 0..n-1 rank within a
(project_id, status_id) column, not a project-wide order. New composite
index idx_cards_project_status_position; existing rows re-ranked.
- PUT /api/projects/{id}/cards/order takes { status_id, card_ids } and sets one
column's contents and order, re-parenting moved-in cards and re-packing their
source column in a single transaction. PATCH status_id appends the card to the
end of the destination column.
58 phpunit tests pass; the frontend type-checks and builds.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
-- `cards.position` was a project-wide sort key. It is now a rank *within a
|
||||
-- column* — the group of cards sharing a (project_id, status_id). The inbox
|
||||
-- (status_id IS NULL) is its own column. The "all tasks" view no longer uses
|
||||
-- position at all (it sorts alphabetically); ordering is a per-column concern
|
||||
-- driven by PUT /api/projects/{id}/cards/order.
|
||||
|
||||
DROP INDEX IF EXISTS idx_cards_project_position;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_cards_project_status_position
|
||||
ON cards (project_id, status_id, position);
|
||||
|
||||
-- Re-pack every existing column to a dense 0..n-1, preserving current order.
|
||||
-- The CTE is evaluated against the pre-update snapshot, so this is safe despite
|
||||
-- writing the same table.
|
||||
WITH ranked (id, rk) AS (
|
||||
SELECT id,
|
||||
row_number() OVER (
|
||||
PARTITION BY project_id, status_id
|
||||
ORDER BY position, id
|
||||
) - 1
|
||||
FROM cards
|
||||
)
|
||||
UPDATE cards
|
||||
SET position = (SELECT rk FROM ranked WHERE ranked.id = cards.id);
|
||||
Reference in New Issue
Block a user