-- Add columns to feedbacks table to track escalation and time taken
ALTER TABLE feedbacks
ADD COLUMN escalated_at DATETIME,
ADD COLUMN time_to_confirm INT(11),
ADD COLUMN time_after_escalation INT(11);

-- fill in created_on column with created_at values if created_on is null
UPDATE feedbacks
SET time_to_confirm = TIMESTAMPDIFF(SECOND, created_on, acknowledged_at)
WHERE acknowledged_at IS NOT NULL;
-- fill in time_after_escalation column with difference between escalated_at and confirmed_at
UPDATE feedbacks
SET time_after_escalation = TIMESTAMPDIFF(SECOND, escalated_at, acknowledged_at)
WHERE escalated_at IS NOT NULL;