Replace status_id with in_progress boolean field

- Remove task_statuses lookup table and StatusID foreign key
- Add InProgress boolean field to Task model
- Add database migration (005_replace_status_with_in_progress)
- Update all handlers, services, and repositories
- Update admin frontend to display in_progress as checkbox/boolean
- Remove Task Statuses tab from admin lookups page
- Update tests to use InProgress instead of StatusID
- Task categorization now uses InProgress for kanban column assignment

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Trey t
2025-12-08 20:48:16 -06:00
parent cb250f108b
commit c5b0225422
43 changed files with 353 additions and 753 deletions

View File

@@ -0,0 +1,45 @@
-- Rollback: Restore status_id foreign key from in_progress boolean
-- Step 1: Recreate the task_taskstatus table
CREATE TABLE IF NOT EXISTS task_taskstatus (
id SERIAL PRIMARY KEY,
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMPTZ,
name VARCHAR(20) NOT NULL,
description TEXT,
color VARCHAR(7),
display_order INTEGER NOT NULL DEFAULT 0
);
-- Step 2: Seed the status lookup data
INSERT INTO task_taskstatus (name, description, color, display_order) VALUES
('Pending', 'Task is waiting to be started', '#808080', 1),
('In Progress', 'Task is currently being worked on', '#3498db', 2),
('Completed', 'Task has been finished', '#27ae60', 3),
('On Hold', 'Task is temporarily paused', '#f39c12', 4),
('Cancelled', 'Task has been cancelled', '#e74c3c', 5)
ON CONFLICT DO NOTHING;
-- Step 3: Add status_id column back
ALTER TABLE task_task ADD COLUMN IF NOT EXISTS status_id INTEGER;
-- Step 4: Migrate data - set status_id based on in_progress flag
-- Set to "In Progress" status if in_progress is true, otherwise "Pending"
UPDATE task_task
SET status_id = (
CASE
WHEN in_progress = true THEN (SELECT id FROM task_taskstatus WHERE name = 'In Progress' LIMIT 1)
ELSE (SELECT id FROM task_taskstatus WHERE name = 'Pending' LIMIT 1)
END
);
-- Step 5: Add foreign key constraint
ALTER TABLE task_task ADD CONSTRAINT fk_task_task_status
FOREIGN KEY (status_id) REFERENCES task_taskstatus(id);
-- Step 6: Drop the in_progress column
ALTER TABLE task_task DROP COLUMN IF EXISTS in_progress;
-- Step 7: Drop the index
DROP INDEX IF EXISTS idx_task_task_in_progress;

View File

@@ -0,0 +1,44 @@
-- Migration: Replace status_id foreign key with in_progress boolean
-- This simplifies the task model since status was only used to determine if a task is "In Progress"
-- Step 1: Add in_progress boolean column with default false
ALTER TABLE task_task ADD COLUMN IF NOT EXISTS in_progress BOOLEAN NOT NULL DEFAULT false;
-- Step 2: Create index on in_progress for query performance
CREATE INDEX IF NOT EXISTS idx_task_task_in_progress ON task_task(in_progress);
-- Step 3: Migrate existing data - set in_progress = true for tasks with "In Progress" status
UPDATE task_task
SET in_progress = true
WHERE status_id IN (
SELECT id FROM task_taskstatus WHERE LOWER(name) = 'in progress'
);
-- Step 4: Drop the foreign key constraint on status_id (if it exists)
-- PostgreSQL syntax - the constraint name might vary
DO $$
BEGIN
-- Try to drop the constraint if it exists
IF EXISTS (
SELECT 1 FROM information_schema.table_constraints
WHERE constraint_name = 'fk_task_task_status'
AND table_name = 'task_task'
) THEN
ALTER TABLE task_task DROP CONSTRAINT fk_task_task_status;
END IF;
-- Also try the gorm auto-generated constraint name
IF EXISTS (
SELECT 1 FROM information_schema.table_constraints
WHERE constraint_name = 'task_task_status_id_fkey'
AND table_name = 'task_task'
) THEN
ALTER TABLE task_task DROP CONSTRAINT task_task_status_id_fkey;
END IF;
END $$;
-- Step 5: Drop the status_id column
ALTER TABLE task_task DROP COLUMN IF EXISTS status_id;
-- Step 6: Drop the task_taskstatus table
DROP TABLE IF EXISTS task_taskstatus;