-- name: GetConfig :one
SELECT ticket_key, ticket_id
FROM appconfig;

-- name: SetNewConfig :one
UPDATE appconfig
SET ticket_id = ticket_id + 1
RETURNING *;

-- name: CreateTicket :one
INSERT INTO tickets (
    key, channelID
) VALUES (
    $1, $2
    )
    RETURNING *;

-- name: ListTickets :many
SELECT * FROM tickets WHERE deleted_at IS NULL;

-- name: ListTicketsWithDeleted :many
SELECT * FROM tickets;

-- name: GetTicketByID :one
SELECT * FROM tickets WHERE id = $1;

-- name: GetTicketByChannelID :one
SELECT * FROM tickets WHERE channelID = $1;

-- name: UpdateTicketByID :exec
UPDATE tickets SET project_git = $1, build_git = $2, folder = $3 WHERE id = $4;

-- name: DeleteTicketByID :exec
UPDATE tickets SET deleted_at = current_timestamp WHERE id = $1;

-- name: DeleteTicketByKey :exec
UPDATE tickets SET deleted_at = current_timestamp WHERE key = $1;