-- name: GetNotificationPrefs :one
SELECT user_id, email_enabled, im_enabled, im_webhook_url_enc, min_severity, updated_at
FROM notification_prefs
WHERE user_id = $1;

-- name: UpsertNotificationPrefs :exec
INSERT INTO notification_prefs (user_id, email_enabled, im_enabled, im_webhook_url_enc, min_severity, updated_at)
VALUES ($1, $2, $3, $4, $5, now())
ON CONFLICT (user_id) DO UPDATE SET
  email_enabled      = EXCLUDED.email_enabled,
  im_enabled         = EXCLUDED.im_enabled,
  im_webhook_url_enc = EXCLUDED.im_webhook_url_enc,
  min_severity       = EXCLUDED.min_severity,
  updated_at         = now();
