This commit is contained in:
11
db/migrations/20250324105016_inc_update.sql
Normal file
11
db/migrations/20250324105016_inc_update.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE incidents RENAME COLUMN subcategory to sub_category;
|
||||
ALTER TABLE "Incoming" RENAME COLUMN subcategory to sub_category;
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE incidents RENAME COLUMN sub_category to subcategory;
|
||||
ALTER TABLE "Incoming" RENAME COLUMN sub_category to subcategory;
|
||||
-- +goose StatementEnd
|
@@ -21,7 +21,7 @@ type Incident struct {
|
||||
AssignmentGroup sql.NullString
|
||||
AssignedTo sql.NullString
|
||||
Category sql.NullString
|
||||
Subcategory sql.NullString
|
||||
SubCategory sql.NullString
|
||||
SysID sql.NullString
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ type Incoming struct {
|
||||
AssignmentGroup sql.NullString
|
||||
AssignedTo sql.NullString
|
||||
Category sql.NullString
|
||||
Subcategory sql.NullString
|
||||
SubCategory sql.NullString
|
||||
CreatedAt sql.NullTime
|
||||
}
|
||||
|
||||
|
@@ -4,7 +4,7 @@ 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", "subcategory", "created_at"
|
||||
"incident_number", "description", "short_description", "urgency", "impact", "state", "external_id", "work_notes", "assignment_group", "assigned_to", "category", "sub_category", "created_at"
|
||||
) VALUES(
|
||||
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
|
||||
)
|
||||
@@ -12,7 +12,7 @@ RETURNING *;
|
||||
|
||||
-- name: CreateIncident :one
|
||||
INSERT INTO incidents (
|
||||
"description", "short_description", "urgency", "impact", "state", "external_id", "assignment_group", "assigned_to", "category", "subcategory", "created_at", "sys_id"
|
||||
"description", "short_description", "urgency", "impact", "state", "external_id", "assignment_group", "assigned_to", "category", "sub_category", "created_at", "sys_id"
|
||||
) VALUES(
|
||||
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
|
||||
)
|
||||
@@ -23,6 +23,11 @@ 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')
|
||||
@@ -40,7 +45,7 @@ SET
|
||||
assignment_group = ?,
|
||||
assigned_to = ?,
|
||||
category = ?,
|
||||
subcategory = ?
|
||||
sub_category = ?
|
||||
WHERE incident_number = ?;
|
||||
|
||||
-- name: GetIncident :one
|
||||
@@ -52,7 +57,8 @@ SELECT * FROM incidents;
|
||||
|
||||
-- name: GetIncidentReport :many
|
||||
SELECT incidents.*, GROUP_CONCAT(worknotes.note, '<br />') AS all_notes
|
||||
FROM incidents LEFT JOIN worknotes ON incidents.incident_number = worknotes.incident_number;
|
||||
FROM incidents LEFT JOIN worknotes ON incidents.incident_number = worknotes.incident_number
|
||||
GROUP BY incidents.id;
|
||||
|
||||
-- name: CreateWorkNote :one
|
||||
INSERT into worknotes (
|
||||
|
@@ -12,11 +12,11 @@ import (
|
||||
|
||||
const createIncident = `-- name: CreateIncident :one
|
||||
INSERT INTO incidents (
|
||||
"description", "short_description", "urgency", "impact", "state", "external_id", "assignment_group", "assigned_to", "category", "subcategory", "created_at", "sys_id"
|
||||
"description", "short_description", "urgency", "impact", "state", "external_id", "assignment_group", "assigned_to", "category", "sub_category", "created_at", "sys_id"
|
||||
) VALUES(
|
||||
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
|
||||
)
|
||||
RETURNING id, external_id, created_at, incident_number, description, short_description, urgency, impact, state, assignment_group, assigned_to, category, subcategory, sys_id
|
||||
RETURNING id, external_id, created_at, incident_number, description, short_description, urgency, impact, state, assignment_group, assigned_to, category, sub_category, sys_id
|
||||
`
|
||||
|
||||
type CreateIncidentParams struct {
|
||||
@@ -29,7 +29,7 @@ type CreateIncidentParams struct {
|
||||
AssignmentGroup sql.NullString
|
||||
AssignedTo sql.NullString
|
||||
Category sql.NullString
|
||||
Subcategory sql.NullString
|
||||
SubCategory sql.NullString
|
||||
CreatedAt sql.NullTime
|
||||
SysID sql.NullString
|
||||
}
|
||||
@@ -45,7 +45,7 @@ func (q *Queries) CreateIncident(ctx context.Context, arg CreateIncidentParams)
|
||||
arg.AssignmentGroup,
|
||||
arg.AssignedTo,
|
||||
arg.Category,
|
||||
arg.Subcategory,
|
||||
arg.SubCategory,
|
||||
arg.CreatedAt,
|
||||
arg.SysID,
|
||||
)
|
||||
@@ -63,7 +63,7 @@ func (q *Queries) CreateIncident(ctx context.Context, arg CreateIncidentParams)
|
||||
&i.AssignmentGroup,
|
||||
&i.AssignedTo,
|
||||
&i.Category,
|
||||
&i.Subcategory,
|
||||
&i.SubCategory,
|
||||
&i.SysID,
|
||||
)
|
||||
return i, err
|
||||
@@ -71,11 +71,11 @@ func (q *Queries) CreateIncident(ctx context.Context, arg CreateIncidentParams)
|
||||
|
||||
const createIncoming = `-- name: CreateIncoming :one
|
||||
INSERT INTO "Incoming" (
|
||||
"incident_number", "description", "short_description", "urgency", "impact", "state", "external_id", "work_notes", "assignment_group", "assigned_to", "category", "subcategory", "created_at"
|
||||
"incident_number", "description", "short_description", "urgency", "impact", "state", "external_id", "work_notes", "assignment_group", "assigned_to", "category", "sub_category", "created_at"
|
||||
) VALUES(
|
||||
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
|
||||
)
|
||||
RETURNING id, incident_number, description, short_description, urgency, impact, state, external_id, work_notes, assignment_group, assigned_to, category, subcategory, created_at
|
||||
RETURNING id, incident_number, description, short_description, urgency, impact, state, external_id, work_notes, assignment_group, assigned_to, category, sub_category, created_at
|
||||
`
|
||||
|
||||
type CreateIncomingParams struct {
|
||||
@@ -90,7 +90,7 @@ type CreateIncomingParams struct {
|
||||
AssignmentGroup sql.NullString
|
||||
AssignedTo sql.NullString
|
||||
Category sql.NullString
|
||||
Subcategory sql.NullString
|
||||
SubCategory sql.NullString
|
||||
CreatedAt sql.NullTime
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ func (q *Queries) CreateIncoming(ctx context.Context, arg CreateIncomingParams)
|
||||
arg.AssignmentGroup,
|
||||
arg.AssignedTo,
|
||||
arg.Category,
|
||||
arg.Subcategory,
|
||||
arg.SubCategory,
|
||||
arg.CreatedAt,
|
||||
)
|
||||
var i Incoming
|
||||
@@ -124,7 +124,7 @@ func (q *Queries) CreateIncoming(ctx context.Context, arg CreateIncomingParams)
|
||||
&i.AssignmentGroup,
|
||||
&i.AssignedTo,
|
||||
&i.Category,
|
||||
&i.Subcategory,
|
||||
&i.SubCategory,
|
||||
&i.CreatedAt,
|
||||
)
|
||||
return i, err
|
||||
@@ -152,7 +152,7 @@ func (q *Queries) CreateWorkNote(ctx context.Context, arg CreateWorkNoteParams)
|
||||
}
|
||||
|
||||
const getIncident = `-- name: GetIncident :one
|
||||
SELECT id, external_id, created_at, incident_number, description, short_description, urgency, impact, state, assignment_group, assigned_to, category, subcategory, sys_id from incidents
|
||||
SELECT id, external_id, created_at, incident_number, description, short_description, urgency, impact, state, assignment_group, assigned_to, category, sub_category, sys_id from incidents
|
||||
WHERE incident_number = ?1
|
||||
`
|
||||
|
||||
@@ -172,15 +172,16 @@ func (q *Queries) GetIncident(ctx context.Context, incidentnumber sql.NullString
|
||||
&i.AssignmentGroup,
|
||||
&i.AssignedTo,
|
||||
&i.Category,
|
||||
&i.Subcategory,
|
||||
&i.SubCategory,
|
||||
&i.SysID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getIncidentReport = `-- name: GetIncidentReport :many
|
||||
SELECT incidents.id, incidents.external_id, incidents.created_at, incidents.incident_number, incidents.description, incidents.short_description, incidents.urgency, incidents.impact, incidents.state, incidents.assignment_group, incidents.assigned_to, incidents.category, incidents.subcategory, incidents.sys_id, GROUP_CONCAT(worknotes.note, '<br />') AS all_notes
|
||||
SELECT incidents.id, incidents.external_id, incidents.created_at, incidents.incident_number, incidents.description, incidents.short_description, incidents.urgency, incidents.impact, incidents.state, incidents.assignment_group, incidents.assigned_to, incidents.category, incidents.sub_category, incidents.sys_id, GROUP_CONCAT(worknotes.note, '<br />') AS all_notes
|
||||
FROM incidents LEFT JOIN worknotes ON incidents.incident_number = worknotes.incident_number
|
||||
GROUP BY incidents.id
|
||||
`
|
||||
|
||||
type GetIncidentReportRow struct {
|
||||
@@ -196,7 +197,7 @@ type GetIncidentReportRow struct {
|
||||
AssignmentGroup sql.NullString
|
||||
AssignedTo sql.NullString
|
||||
Category sql.NullString
|
||||
Subcategory sql.NullString
|
||||
SubCategory sql.NullString
|
||||
SysID sql.NullString
|
||||
AllNotes string
|
||||
}
|
||||
@@ -223,7 +224,7 @@ func (q *Queries) GetIncidentReport(ctx context.Context) ([]GetIncidentReportRow
|
||||
&i.AssignmentGroup,
|
||||
&i.AssignedTo,
|
||||
&i.Category,
|
||||
&i.Subcategory,
|
||||
&i.SubCategory,
|
||||
&i.SysID,
|
||||
&i.AllNotes,
|
||||
); err != nil {
|
||||
@@ -241,7 +242,7 @@ func (q *Queries) GetIncidentReport(ctx context.Context) ([]GetIncidentReportRow
|
||||
}
|
||||
|
||||
const listIncidents = `-- name: ListIncidents :many
|
||||
SELECT id, external_id, created_at, incident_number, description, short_description, urgency, impact, state, assignment_group, assigned_to, category, subcategory, sys_id FROM incidents
|
||||
SELECT id, external_id, created_at, incident_number, description, short_description, urgency, impact, state, assignment_group, assigned_to, category, sub_category, sys_id FROM incidents
|
||||
`
|
||||
|
||||
func (q *Queries) ListIncidents(ctx context.Context) ([]Incident, error) {
|
||||
@@ -266,7 +267,7 @@ func (q *Queries) ListIncidents(ctx context.Context) ([]Incident, error) {
|
||||
&i.AssignmentGroup,
|
||||
&i.AssignedTo,
|
||||
&i.Category,
|
||||
&i.Subcategory,
|
||||
&i.SubCategory,
|
||||
&i.SysID,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
@@ -283,7 +284,7 @@ func (q *Queries) ListIncidents(ctx context.Context) ([]Incident, error) {
|
||||
}
|
||||
|
||||
const listIncoming = `-- name: ListIncoming :many
|
||||
SELECT id, incident_number, description, short_description, urgency, impact, state, external_id, work_notes, assignment_group, assigned_to, category, subcategory, created_at FROM "Incoming"
|
||||
SELECT id, incident_number, description, short_description, urgency, impact, state, external_id, work_notes, assignment_group, assigned_to, category, sub_category, created_at FROM "Incoming"
|
||||
ORDER BY "id"
|
||||
`
|
||||
|
||||
@@ -309,7 +310,7 @@ func (q *Queries) ListIncoming(ctx context.Context) ([]Incoming, error) {
|
||||
&i.AssignmentGroup,
|
||||
&i.AssignedTo,
|
||||
&i.Category,
|
||||
&i.Subcategory,
|
||||
&i.SubCategory,
|
||||
&i.CreatedAt,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
@@ -337,7 +338,7 @@ SET
|
||||
assignment_group = ?,
|
||||
assigned_to = ?,
|
||||
category = ?,
|
||||
subcategory = ?
|
||||
sub_category = ?
|
||||
WHERE incident_number = ?
|
||||
`
|
||||
|
||||
@@ -351,7 +352,7 @@ type UpdateIncidentParams struct {
|
||||
AssignmentGroup sql.NullString
|
||||
AssignedTo sql.NullString
|
||||
Category sql.NullString
|
||||
Subcategory sql.NullString
|
||||
SubCategory sql.NullString
|
||||
IncidentNumber sql.NullString
|
||||
}
|
||||
|
||||
@@ -366,7 +367,7 @@ func (q *Queries) UpdateIncident(ctx context.Context, arg UpdateIncidentParams)
|
||||
arg.AssignmentGroup,
|
||||
arg.AssignedTo,
|
||||
arg.Category,
|
||||
arg.Subcategory,
|
||||
arg.SubCategory,
|
||||
arg.IncidentNumber,
|
||||
)
|
||||
return err
|
||||
@@ -388,6 +389,22 @@ func (q *Queries) UpdateIncidentNumber(ctx context.Context, arg UpdateIncidentNu
|
||||
return err
|
||||
}
|
||||
|
||||
const updateIncidentNumberSysId = `-- name: UpdateIncidentNumberSysId :exec
|
||||
UPDATE incidents
|
||||
SET incident_number = ?1
|
||||
WHERE sys_id = ?2
|
||||
`
|
||||
|
||||
type UpdateIncidentNumberSysIdParams struct {
|
||||
IncidentNumber sql.NullString
|
||||
SysId sql.NullString
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateIncidentNumberSysId(ctx context.Context, arg UpdateIncidentNumberSysIdParams) error {
|
||||
_, err := q.db.ExecContext(ctx, updateIncidentNumberSysId, arg.IncidentNumber, arg.SysId)
|
||||
return err
|
||||
}
|
||||
|
||||
const updateIncidentState = `-- name: UpdateIncidentState :exec
|
||||
UPDATE incidents
|
||||
SET state = ?1
|
||||
|
Reference in New Issue
Block a user