CREATE TABLE sla_policies (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  queue_id UUID REFERENCES queues(id) ON DELETE SET NULL,
  name TEXT NOT NULL,
  description TEXT,
  response_time_minutes INTEGER,
  resolution_time_minutes INTEGER,
  disabled BOOLEAN NOT NULL DEFAULT false,
  created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX sla_policies_queue_id_idx ON sla_policies(queue_id);

ALTER TABLE tickets ADD COLUMN sla_response_deadline TIMESTAMPTZ;
ALTER TABLE tickets ADD COLUMN sla_resolution_deadline TIMESTAMPTZ;
ALTER TABLE tickets ADD COLUMN sla_breached TEXT;
