-- name: CreateURL :one
INSERT INTO urls (created_at, expires_at, long_url, short_code, is_active)
VALUES (
  $1,
  $2,
  $3,
  $4,
  $5
)
RETURNING *;

-- name: GetURLs :many
SELECT * FROM urls;

-- name: GetURLByShortCode :one
SELECT url_id, long_url FROM urls WHERE is_active = true AND short_code = $1;

-- name: SetActive :one
UPDATE urls SET is_active = $1 WHERE url_id = $2 RETURNING *;

-- name: DeleteURL :one
DELETE FROM urls WHERE url_id = $1 RETURNING *;