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

package db

import (
	"context"
)

const getRoadmapSyncIdentityByMilestonePath = `-- name: GetRoadmapSyncIdentityByMilestonePath :one
SELECT id, shape, roadmap_milestone_path, roadmap_item_id, provider, tenant, project, work_item_id, parent_work_item_id, provider_revision, roadmap_revision, created_at, updated_at
FROM roadmap_sync_identities
WHERE roadmap_milestone_path = $1
`

func (q *Queries) GetRoadmapSyncIdentityByMilestonePath(ctx context.Context, roadmapMilestonePath string) (RoadmapSyncIdentity, error) {
	row := q.db.QueryRow(ctx, getRoadmapSyncIdentityByMilestonePath, roadmapMilestonePath)
	var i RoadmapSyncIdentity
	err := row.Scan(
		&i.ID,
		&i.Shape,
		&i.RoadmapMilestonePath,
		&i.RoadmapItemID,
		&i.Provider,
		&i.Tenant,
		&i.Project,
		&i.WorkItemID,
		&i.ParentWorkItemID,
		&i.ProviderRevision,
		&i.RoadmapRevision,
		&i.CreatedAt,
		&i.UpdatedAt,
	)
	return i, err
}

const getRoadmapSyncIdentityByWorkItem = `-- name: GetRoadmapSyncIdentityByWorkItem :one
SELECT id, shape, roadmap_milestone_path, roadmap_item_id, provider, tenant, project, work_item_id, parent_work_item_id, provider_revision, roadmap_revision, created_at, updated_at
FROM roadmap_sync_identities
WHERE provider = $1 AND tenant = $2 AND project = $3 AND work_item_id = $4
`

type GetRoadmapSyncIdentityByWorkItemParams struct {
	Provider   string `json:"provider"`
	Tenant     string `json:"tenant"`
	Project    string `json:"project"`
	WorkItemID string `json:"work_item_id"`
}

func (q *Queries) GetRoadmapSyncIdentityByWorkItem(ctx context.Context, arg GetRoadmapSyncIdentityByWorkItemParams) (RoadmapSyncIdentity, error) {
	row := q.db.QueryRow(ctx, getRoadmapSyncIdentityByWorkItem,
		arg.Provider,
		arg.Tenant,
		arg.Project,
		arg.WorkItemID,
	)
	var i RoadmapSyncIdentity
	err := row.Scan(
		&i.ID,
		&i.Shape,
		&i.RoadmapMilestonePath,
		&i.RoadmapItemID,
		&i.Provider,
		&i.Tenant,
		&i.Project,
		&i.WorkItemID,
		&i.ParentWorkItemID,
		&i.ProviderRevision,
		&i.RoadmapRevision,
		&i.CreatedAt,
		&i.UpdatedAt,
	)
	return i, err
}

const upsertRoadmapSyncIdentityByWorkItem = `-- name: UpsertRoadmapSyncIdentityByWorkItem :one
INSERT INTO roadmap_sync_identities (
    shape, roadmap_milestone_path, roadmap_item_id, provider, tenant, project, work_item_id, parent_work_item_id, provider_revision, roadmap_revision
)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
ON CONFLICT (provider, tenant, project, work_item_id)
DO UPDATE SET
    shape = EXCLUDED.shape,
    roadmap_item_id = EXCLUDED.roadmap_item_id,
    parent_work_item_id = EXCLUDED.parent_work_item_id,
    provider_revision = EXCLUDED.provider_revision,
    roadmap_revision = EXCLUDED.roadmap_revision,
    updated_at = now()
WHERE roadmap_sync_identities.roadmap_milestone_path = EXCLUDED.roadmap_milestone_path
RETURNING id, shape, roadmap_milestone_path, roadmap_item_id, provider, tenant, project, work_item_id, parent_work_item_id, provider_revision, roadmap_revision, created_at, updated_at
`

type UpsertRoadmapSyncIdentityByWorkItemParams struct {
	Shape                string  `json:"shape"`
	RoadmapMilestonePath string  `json:"roadmap_milestone_path"`
	RoadmapItemID        string  `json:"roadmap_item_id"`
	Provider             string  `json:"provider"`
	Tenant               string  `json:"tenant"`
	Project              string  `json:"project"`
	WorkItemID           string  `json:"work_item_id"`
	ParentWorkItemID     string  `json:"parent_work_item_id"`
	ProviderRevision     *string `json:"provider_revision"`
	RoadmapRevision      *string `json:"roadmap_revision"`
}

func (q *Queries) UpsertRoadmapSyncIdentityByWorkItem(ctx context.Context, arg UpsertRoadmapSyncIdentityByWorkItemParams) (RoadmapSyncIdentity, error) {
	row := q.db.QueryRow(ctx, upsertRoadmapSyncIdentityByWorkItem,
		arg.Shape,
		arg.RoadmapMilestonePath,
		arg.RoadmapItemID,
		arg.Provider,
		arg.Tenant,
		arg.Project,
		arg.WorkItemID,
		arg.ParentWorkItemID,
		arg.ProviderRevision,
		arg.RoadmapRevision,
	)
	var i RoadmapSyncIdentity
	err := row.Scan(
		&i.ID,
		&i.Shape,
		&i.RoadmapMilestonePath,
		&i.RoadmapItemID,
		&i.Provider,
		&i.Tenant,
		&i.Project,
		&i.WorkItemID,
		&i.ParentWorkItemID,
		&i.ProviderRevision,
		&i.RoadmapRevision,
		&i.CreatedAt,
		&i.UpdatedAt,
	)
	return i, err
}
