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

package db

import (
	"context"
)

const listRoadmapSyncSteps = `-- name: ListRoadmapSyncSteps :many
SELECT id, roadmap_sync_identity_id, step, completed_at
FROM roadmap_sync_steps
WHERE roadmap_sync_identity_id = $1
ORDER BY id
`

func (q *Queries) ListRoadmapSyncSteps(ctx context.Context, roadmapSyncIdentityID int64) ([]RoadmapSyncStep, error) {
	rows, err := q.db.Query(ctx, listRoadmapSyncSteps, roadmapSyncIdentityID)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	var items []RoadmapSyncStep
	for rows.Next() {
		var i RoadmapSyncStep
		if err := rows.Scan(
			&i.ID,
			&i.RoadmapSyncIdentityID,
			&i.Step,
			&i.CompletedAt,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const markRoadmapSyncStepCompleted = `-- name: MarkRoadmapSyncStepCompleted :one
INSERT INTO roadmap_sync_steps (roadmap_sync_identity_id, step)
VALUES ($1, $2)
ON CONFLICT (roadmap_sync_identity_id, step)
DO UPDATE SET roadmap_sync_identity_id = EXCLUDED.roadmap_sync_identity_id
RETURNING id, roadmap_sync_identity_id, step, completed_at
`

type MarkRoadmapSyncStepCompletedParams struct {
	RoadmapSyncIdentityID int64  `json:"roadmap_sync_identity_id"`
	Step                  string `json:"step"`
}

func (q *Queries) MarkRoadmapSyncStepCompleted(ctx context.Context, arg MarkRoadmapSyncStepCompletedParams) (RoadmapSyncStep, error) {
	row := q.db.QueryRow(ctx, markRoadmapSyncStepCompleted, arg.RoadmapSyncIdentityID, arg.Step)
	var i RoadmapSyncStep
	err := row.Scan(
		&i.ID,
		&i.RoadmapSyncIdentityID,
		&i.Step,
		&i.CompletedAt,
	)
	return i, err
}
