-- name: SelectUploadsOfSite :many
SELECT * FROM uploads WHERE site_id = ? ORDER BY created_at DESC;

-- name: SelectUploadByID :one
SELECT * FROM uploads WHERE id = ? LIMIT 1;

-- name: SelectUploadBySiteIDAndSlug :one
SELECT * FROM uploads WHERE site_id = ? AND slug = ? LIMIT 1;

-- name: InsertUpload :exec
INSERT INTO uploads (
    site_id,
    guid,
    mime_type,
    filename,
    file_size,
    slug,
    alt,
    created_at
) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
RETURNING id;

-- name: UpdateUpload :exec
UPDATE uploads SET alt = ? WHERE id = ?;

-- name: DeleteUpload :exec
DELETE FROM uploads WHERE id = ?;