-- =====================================================================
-- Migration: Add COLOR_HEX column to TTM_TASK_STATUS_MASTER
-- Run this once on your database if the column doesn't exist yet.
-- =====================================================================

-- Add COLOR_HEX column (safe to run even if already exists via ALTER IGNORE)
ALTER TABLE `TTM_TASK_STATUS_MASTER`
  ADD COLUMN IF NOT EXISTS `COLOR_HEX` varchar(20) DEFAULT NULL AFTER `DESCRIPTION`;

-- Seed initial task statuses if table is empty
INSERT IGNORE INTO `TTM_TASK_STATUS_MASTER`
  (`STATUS_CODE`, `STATUS_NAME`, `DESCRIPTION`, `COLOR_HEX`, `IS_TERMINAL`, `DISPLAY_ORDER`)
VALUES
  ('PENDING_TEAM', 'Pending Team',  'Task created, FL has not assigned team yet',          '#6c757d', 0, 1),
  ('ACTIVE',       'Active',        'FL assigned team, work is in progress',               '#0d6efd', 0, 2),
  ('OVERDUE',      'Overdue',       'Client deadline passed and task not yet completed',   '#fd7e14', 0, 3),
  ('COMPLETED',    'Completed',     'All functions completed, deliverables sent to client','#198754', 1, 4),
  ('DEACTIVATED',  'Deactivated',   'Service cancelled, no new instances will generate',  '#dc3545', 1, 5),
  ('ARCHIVED',     'Archived',      'Past retention period, moved to read-only archive',  '#adb5bd', 1, 6);

SELECT 'Migration complete. TTM_TASK_STATUS_MASTER seeded.' AS result;
