-- Migration 063: Ticket Enhancements (Types, Internal Notes, Worklog Visibility)

-- 1. Add ticket_type and internal_note to tickets
-- Defaults: ticket_type='incident' (for existing rows)
ALTER TABLE tticket_tickets 
ADD COLUMN IF NOT EXISTS ticket_type VARCHAR(50) DEFAULT 'incident',
ADD COLUMN IF NOT EXISTS internal_note TEXT;

-- 2. Add is_internal to worklog (singular)
ALTER TABLE tticket_worklog 
ADD COLUMN IF NOT EXISTS is_internal BOOLEAN DEFAULT FALSE;

-- 3. Create index for performance on filtering by type
CREATE INDEX IF NOT EXISTS idx_tticket_tickets_type ON tticket_tickets(ticket_type);
