Add incident created_at
This commit is contained in:
parent
3a4c90d12f
commit
04977b5468
7 changed files with 21 additions and 3 deletions
|
@ -61,6 +61,7 @@ INSERT INTO incidents (
|
|||
name,
|
||||
owner,
|
||||
description,
|
||||
created_at,
|
||||
start_time,
|
||||
end_time,
|
||||
location,
|
||||
|
@ -70,12 +71,13 @@ INSERT INTO incidents (
|
|||
$2,
|
||||
$3,
|
||||
$4,
|
||||
NOW(),
|
||||
$5,
|
||||
$6,
|
||||
$7,
|
||||
$8
|
||||
)
|
||||
RETURNING id, name, owner, description, start_time, end_time, location, metadata
|
||||
RETURNING id, name, owner, description, created_at, start_time, end_time, location, metadata
|
||||
`
|
||||
|
||||
type CreateIncidentParams struct {
|
||||
|
@ -106,6 +108,7 @@ func (q *Queries) CreateIncident(ctx context.Context, arg CreateIncidentParams)
|
|||
&i.Name,
|
||||
&i.Owner,
|
||||
&i.Description,
|
||||
&i.CreatedAt,
|
||||
&i.StartTime,
|
||||
&i.EndTime,
|
||||
&i.Location,
|
||||
|
@ -129,6 +132,7 @@ SELECT
|
|||
i.name,
|
||||
i.owner,
|
||||
i.description,
|
||||
i.created_at,
|
||||
i.start_time,
|
||||
i.end_time,
|
||||
i.location,
|
||||
|
@ -145,6 +149,7 @@ func (q *Queries) GetIncident(ctx context.Context, id uuid.UUID) (Incident, erro
|
|||
&i.Name,
|
||||
&i.Owner,
|
||||
&i.Description,
|
||||
&i.CreatedAt,
|
||||
&i.StartTime,
|
||||
&i.EndTime,
|
||||
&i.Location,
|
||||
|
@ -297,6 +302,7 @@ SELECT
|
|||
i.name,
|
||||
i.owner,
|
||||
i.description,
|
||||
i.created_at,
|
||||
i.start_time,
|
||||
i.end_time,
|
||||
i.location,
|
||||
|
@ -335,6 +341,7 @@ type ListIncidentsPRow struct {
|
|||
Name string `json:"name"`
|
||||
Owner int `json:"owner"`
|
||||
Description *string `json:"description"`
|
||||
CreatedAt pgtype.Timestamptz `json:"createdAt"`
|
||||
StartTime pgtype.Timestamptz `json:"startTime"`
|
||||
EndTime pgtype.Timestamptz `json:"endTime"`
|
||||
Location []byte `json:"location"`
|
||||
|
@ -363,6 +370,7 @@ func (q *Queries) ListIncidentsP(ctx context.Context, arg ListIncidentsPParams)
|
|||
&i.Name,
|
||||
&i.Owner,
|
||||
&i.Description,
|
||||
&i.CreatedAt,
|
||||
&i.StartTime,
|
||||
&i.EndTime,
|
||||
&i.Location,
|
||||
|
@ -411,7 +419,7 @@ SET
|
|||
metadata = COALESCE($6, metadata)
|
||||
WHERE
|
||||
id = $7
|
||||
RETURNING id, name, owner, description, start_time, end_time, location, metadata
|
||||
RETURNING id, name, owner, description, created_at, start_time, end_time, location, metadata
|
||||
`
|
||||
|
||||
type UpdateIncidentParams struct {
|
||||
|
@ -440,6 +448,7 @@ func (q *Queries) UpdateIncident(ctx context.Context, arg UpdateIncidentParams)
|
|||
&i.Name,
|
||||
&i.Owner,
|
||||
&i.Description,
|
||||
&i.CreatedAt,
|
||||
&i.StartTime,
|
||||
&i.EndTime,
|
||||
&i.Location,
|
||||
|
|
|
@ -60,6 +60,7 @@ type Incident struct {
|
|||
Name string `json:"name,omitempty"`
|
||||
Owner int `json:"owner,omitempty"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
CreatedAt pgtype.Timestamptz `json:"createdAt,omitempty"`
|
||||
StartTime pgtype.Timestamptz `json:"startTime,omitempty"`
|
||||
EndTime pgtype.Timestamptz `json:"endTime,omitempty"`
|
||||
Location []byte `json:"location,omitempty"`
|
||||
|
|
|
@ -19,6 +19,7 @@ type Incident struct {
|
|||
Owner users.UserID `json:"owner"`
|
||||
Name string `json:"name"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
CreatedAt jsontypes.Time `json:"createdAt"`
|
||||
StartTime *jsontypes.Time `json:"startTime,omitempty"`
|
||||
EndTime *jsontypes.Time `json:"endTime,omitempty"`
|
||||
Location jsontypes.Location `json:"location,omitempty"`
|
||||
|
|
|
@ -231,6 +231,7 @@ func fromDBIncident(id uuid.UUID, d database.Incident) incidents.Incident {
|
|||
Owner: users.UserID(d.Owner),
|
||||
Name: d.Name,
|
||||
Description: d.Description,
|
||||
CreatedAt: jsontypes.Time(d.CreatedAt.Time),
|
||||
StartTime: jsontypes.TimePtrFromTSTZ(d.StartTime),
|
||||
EndTime: jsontypes.TimePtrFromTSTZ(d.EndTime),
|
||||
Metadata: d.Metadata,
|
||||
|
@ -250,6 +251,7 @@ func fromDBListInPRow(id uuid.UUID, d database.ListIncidentsPRow) Incident {
|
|||
Owner: users.UserID(d.Owner),
|
||||
Name: d.Name,
|
||||
Description: d.Description,
|
||||
CreatedAt: jsontypes.Time(d.CreatedAt.Time),
|
||||
StartTime: jsontypes.TimePtrFromTSTZ(d.StartTime),
|
||||
EndTime: jsontypes.TimePtrFromTSTZ(d.EndTime),
|
||||
Metadata: d.Metadata,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.33.0
|
||||
// protoc v5.28.3
|
||||
// protoc v5.29.3
|
||||
// source: stillbox.proto
|
||||
|
||||
package pb
|
||||
|
|
|
@ -143,6 +143,7 @@ CREATE TABLE IF NOT EXISTS incidents(
|
|||
name TEXT NOT NULL,
|
||||
owner INTEGER NOT NULL,
|
||||
description TEXT,
|
||||
created_at TIMESTAMPTZ,
|
||||
start_time TIMESTAMPTZ,
|
||||
end_time TIMESTAMPTZ,
|
||||
location JSONB,
|
||||
|
|
|
@ -42,6 +42,7 @@ INSERT INTO incidents (
|
|||
name,
|
||||
owner,
|
||||
description,
|
||||
created_at,
|
||||
start_time,
|
||||
end_time,
|
||||
location,
|
||||
|
@ -51,6 +52,7 @@ INSERT INTO incidents (
|
|||
@name,
|
||||
@owner,
|
||||
sqlc.narg('description'),
|
||||
NOW(),
|
||||
sqlc.narg('start_time'),
|
||||
sqlc.narg('end_time'),
|
||||
sqlc.narg('location'),
|
||||
|
@ -65,6 +67,7 @@ SELECT
|
|||
i.name,
|
||||
i.owner,
|
||||
i.description,
|
||||
i.created_at,
|
||||
i.start_time,
|
||||
i.end_time,
|
||||
i.location,
|
||||
|
@ -160,6 +163,7 @@ SELECT
|
|||
i.name,
|
||||
i.owner,
|
||||
i.description,
|
||||
i.created_at,
|
||||
i.start_time,
|
||||
i.end_time,
|
||||
i.location,
|
||||
|
|
Loading…
Add table
Reference in a new issue