// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.31.1
// source: changelog.sql

package gen

import (
	"context"
)

const maxChangeLogSeq = `-- name: MaxChangeLogSeq :one
SELECT CAST(COALESCE(MAX(seq), 0) AS INTEGER) AS seq FROM change_log
`

func (q *Queries) MaxChangeLogSeq(ctx context.Context) (int64, error) {
	row := q.db.QueryRowContext(ctx, maxChangeLogSeq)
	var seq int64
	err := row.Scan(&seq)
	return seq, err
}

const readChangeLogAfter = `-- name: ReadChangeLogAfter :many
SELECT seq, project_id, session_id, event_type, payload, created_at
FROM change_log WHERE seq > ? ORDER BY seq LIMIT ?
`

type ReadChangeLogAfterParams struct {
	Seq   int64
	Limit int64
}

func (q *Queries) ReadChangeLogAfter(ctx context.Context, arg ReadChangeLogAfterParams) ([]ChangeLog, error) {
	rows, err := q.db.QueryContext(ctx, readChangeLogAfter, arg.Seq, arg.Limit)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []ChangeLog{}
	for rows.Next() {
		var i ChangeLog
		if err := rows.Scan(
			&i.Seq,
			&i.ProjectID,
			&i.SessionID,
			&i.EventType,
			&i.Payload,
			&i.CreatedAt,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Close(); err != nil {
		return nil, err
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}
