initial version of endpoint
This commit is contained in:
13
db/migrations/20250322100927_incidents.sql
Normal file
13
db/migrations/20250322100927_incidents.sql
Normal file
@@ -0,0 +1,13 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
CREATE TABLE incidents (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
external_id TEXT NOT NULL,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE IF EXISTS incidents;
|
||||
-- +goose StatementEnd
|
@@ -8,6 +8,12 @@ import (
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
type Incident struct {
|
||||
ID int64
|
||||
ExternalID string
|
||||
CreatedAt sql.NullTime
|
||||
}
|
||||
|
||||
type Incoming struct {
|
||||
ID int64
|
||||
IncidentNumber sql.NullString
|
||||
@@ -23,4 +29,4 @@ type Incoming struct {
|
||||
Category sql.NullString
|
||||
Subcategory sql.NullString
|
||||
CreatedAt sql.NullTime
|
||||
}
|
||||
}
|
||||
|
@@ -9,4 +9,9 @@ INSERT INTO "Incoming" (
|
||||
) VALUES(
|
||||
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
|
||||
)
|
||||
RETURNING *;
|
||||
RETURNING *;
|
||||
|
||||
-- name: CreateIncident :one
|
||||
INSERT INTO incidents (external_id)
|
||||
VALUES (?)
|
||||
RETURNING id;
|
||||
|
@@ -10,6 +10,19 @@ import (
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
const createIncident = `-- name: CreateIncident :one
|
||||
INSERT INTO incidents (external_id)
|
||||
VALUES (?)
|
||||
RETURNING id
|
||||
`
|
||||
|
||||
func (q *Queries) CreateIncident(ctx context.Context, externalID string) (int64, error) {
|
||||
row := q.db.QueryRowContext(ctx, createIncident, externalID)
|
||||
var id int64
|
||||
err := row.Scan(&id)
|
||||
return id, err
|
||||
}
|
||||
|
||||
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"
|
||||
|
Reference in New Issue
Block a user