-- Database update script

-- Add team_member column if it doesn't exist
ALTER TABLE actions ADD COLUMN IF NOT EXISTS team_member VARCHAR(100);

-- Add status column if it doesn't exist
ALTER TABLE actions ADD COLUMN IF NOT EXISTS status VARCHAR(50) DEFAULT 'No Status';

-- Update existing records to have a default status if their status is NULL
UPDATE actions SET status = 'No Status' WHERE status IS NULL;

-- Update completed actions to have 'Done' status
UPDATE actions SET status = 'Done' WHERE completed = TRUE AND status = 'No Status';

-- For the sake of consistency, ensure actions with 'Done' status are also marked as completed
UPDATE actions SET completed = TRUE WHERE status = 'Done' AND completed = FALSE;
