All checks were successful
continuous-integration/drone/push Build is passing
69 lines
1.9 KiB
SQL
69 lines
1.9 KiB
SQL
-- name: ListIncoming :many
|
|
SELECT * FROM "Incoming"
|
|
ORDER BY "id";
|
|
|
|
-- name: CreateIncoming :one
|
|
INSERT INTO "Incoming" (
|
|
"incident_number", "description", "short_description", "urgency", "impact", "state", "external_id", "work_notes", "assignment_group", "assigned_to", "category", "sub_category", "created_at"
|
|
) VALUES(
|
|
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
|
|
)
|
|
RETURNING *;
|
|
|
|
-- name: CreateIncident :one
|
|
INSERT INTO incidents (
|
|
"description", "short_description", "urgency", "impact", "state", "external_id", "assignment_group", "assigned_to", "category", "sub_category", "created_at", "sys_id"
|
|
) VALUES(
|
|
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
|
|
)
|
|
RETURNING *;
|
|
|
|
-- name: UpdateIncidentNumber :exec
|
|
UPDATE incidents
|
|
SET incident_number = sqlc.arg('incidentNumber')
|
|
WHERE external_id = sqlc.arg('externalId');
|
|
|
|
-- name: UpdateIncidentNumberSysId :exec
|
|
UPDATE incidents
|
|
SET incident_number = sqlc.arg('incidentNumber')
|
|
WHERE sys_id = sqlc.arg('sysId');
|
|
|
|
-- name: UpdateIncidentState :exec
|
|
UPDATE incidents
|
|
SET state = sqlc.arg('state')
|
|
WHERE incident_number = sqlc.arg('incidentNumber');
|
|
|
|
-- name: UpdateIncident :exec
|
|
UPDATE incidents
|
|
SET
|
|
external_id = ?,
|
|
description = ?,
|
|
short_description = ?,
|
|
urgency = ?,
|
|
impact = ?,
|
|
state = ?,
|
|
assignment_group = ?,
|
|
assigned_to = ?,
|
|
category = ?,
|
|
sub_category = ?
|
|
WHERE incident_number = ?;
|
|
|
|
-- name: GetIncident :one
|
|
SELECT * from incidents
|
|
WHERE incident_number = sqlc.arg('incidentNumber');
|
|
|
|
-- name: ListIncidents :many
|
|
SELECT * FROM incidents;
|
|
|
|
-- name: GetIncidentReport :many
|
|
SELECT incidents.*, IFNULL(GROUP_CONCAT(worknotes.note, '<br />'), ' ') AS all_notes
|
|
FROM incidents LEFT JOIN worknotes ON incidents.incident_number = worknotes.incident_number
|
|
GROUP BY incidents.id;
|
|
|
|
-- name: CreateWorkNote :one
|
|
INSERT into worknotes (
|
|
"incident_number", "note", "created_at"
|
|
) VALUES(
|
|
?, ?, CURRENT_TIMESTAMP
|
|
)
|
|
RETURNING *; |