BEGIN;

UPDATE projects
SET created_at = strftime('%Y-%m-%dT%H:%M:%fZ', created_at)
WHERE created_at IS NOT NULL
  AND strftime('%Y-%m-%dT%H:%M:%fZ', created_at) IS NOT NULL;

UPDATE watched_trackers
SET created_at = strftime('%Y-%m-%dT%H:%M:%fZ', created_at)
WHERE created_at IS NOT NULL
  AND strftime('%Y-%m-%dT%H:%M:%fZ', created_at) IS NOT NULL;

UPDATE watched_trackers
SET last_polled_at = strftime('%Y-%m-%dT%H:%M:%fZ', last_polled_at)
WHERE last_polled_at IS NOT NULL
  AND strftime('%Y-%m-%dT%H:%M:%fZ', last_polled_at) IS NOT NULL;

UPDATE processed_tickets
SET detected_at = strftime('%Y-%m-%dT%H:%M:%fZ', detected_at)
WHERE detected_at IS NOT NULL
  AND strftime('%Y-%m-%dT%H:%M:%fZ', detected_at) IS NOT NULL;

UPDATE processed_tickets
SET processed_at = strftime('%Y-%m-%dT%H:%M:%fZ', processed_at)
WHERE processed_at IS NOT NULL
  AND strftime('%Y-%m-%dT%H:%M:%fZ', processed_at) IS NOT NULL;

UPDATE worktrees
SET created_at = strftime('%Y-%m-%dT%H:%M:%fZ', created_at)
WHERE created_at IS NOT NULL
  AND strftime('%Y-%m-%dT%H:%M:%fZ', created_at) IS NOT NULL;

UPDATE worktrees
SET merged_at = strftime('%Y-%m-%dT%H:%M:%fZ', merged_at)
WHERE merged_at IS NOT NULL
  AND strftime('%Y-%m-%dT%H:%M:%fZ', merged_at) IS NOT NULL;

UPDATE notifications
SET created_at = strftime('%Y-%m-%dT%H:%M:%fZ', created_at)
WHERE created_at IS NOT NULL
  AND strftime('%Y-%m-%dT%H:%M:%fZ', created_at) IS NOT NULL;

UPDATE agents
SET created_at = strftime('%Y-%m-%dT%H:%M:%fZ', created_at)
WHERE created_at IS NOT NULL
  AND strftime('%Y-%m-%dT%H:%M:%fZ', created_at) IS NOT NULL;

UPDATE agents
SET updated_at = strftime('%Y-%m-%dT%H:%M:%fZ', updated_at)
WHERE updated_at IS NOT NULL
  AND strftime('%Y-%m-%dT%H:%M:%fZ', updated_at) IS NOT NULL;

UPDATE project_modules
SET created_at = strftime('%Y-%m-%dT%H:%M:%fZ', created_at)
WHERE created_at IS NOT NULL
  AND strftime('%Y-%m-%dT%H:%M:%fZ', created_at) IS NOT NULL;

UPDATE project_modules
SET updated_at = strftime('%Y-%m-%dT%H:%M:%fZ', updated_at)
WHERE updated_at IS NOT NULL
  AND strftime('%Y-%m-%dT%H:%M:%fZ', updated_at) IS NOT NULL;

UPDATE project_live_sessions
SET created_at = strftime('%Y-%m-%dT%H:%M:%fZ', created_at)
WHERE created_at IS NOT NULL
  AND strftime('%Y-%m-%dT%H:%M:%fZ', created_at) IS NOT NULL;

UPDATE project_live_sessions
SET updated_at = strftime('%Y-%m-%dT%H:%M:%fZ', updated_at)
WHERE updated_at IS NOT NULL
  AND strftime('%Y-%m-%dT%H:%M:%fZ', updated_at) IS NOT NULL;

UPDATE project_live_messages
SET created_at = strftime('%Y-%m-%dT%H:%M:%fZ', created_at)
WHERE created_at IS NOT NULL
  AND strftime('%Y-%m-%dT%H:%M:%fZ', created_at) IS NOT NULL;

UPDATE project_agent_tasks
SET created_at = strftime('%Y-%m-%dT%H:%M:%fZ', created_at)
WHERE created_at IS NOT NULL
  AND strftime('%Y-%m-%dT%H:%M:%fZ', created_at) IS NOT NULL;

UPDATE project_agent_tasks
SET started_at = strftime('%Y-%m-%dT%H:%M:%fZ', started_at)
WHERE started_at IS NOT NULL
  AND strftime('%Y-%m-%dT%H:%M:%fZ', started_at) IS NOT NULL;

UPDATE project_agent_tasks
SET finished_at = strftime('%Y-%m-%dT%H:%M:%fZ', finished_at)
WHERE finished_at IS NOT NULL
  AND strftime('%Y-%m-%dT%H:%M:%fZ', finished_at) IS NOT NULL;

COMMIT;
