-- name: InsertPage :one
INSERT INTO pages (
    site_id,
    bundle_id,
    name,
    name_provenance,
    title,
    post_type_id,
    body,
    state,
    props,
    role,
    publish_date,
    created_at,
    updated_at
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $12)
RETURNING id;

-- name: UpdatePage :exec
UPDATE pages SET
    site_id = $2,
    bundle_id = $3,
    name = $4,
    name_provenance = $5,
    title = $6,
    post_type_id = $7,
    role = $8,
    body = $9,
    state = $10,
    props = $11,
    publish_date = $12,
    created_at = $13,
    updated_at = $14
WHERE id = $1;

-- name: ListPublishablePages :many
SELECT *
FROM pages
WHERE id > $1 AND site_id = $2 AND state = 'published'
ORDER BY id LIMIT 100;

-- name: ListPages :many
SELECT * FROM pages WHERE site_id = $1 ORDER BY name ASC LIMIT 25;

-- name: GetPageWithID :one
SELECT * FROM pages WHERE id = $1;

-- name: DeletePageWithID :exec
DELETE FROM pages WHERE id = $1;