diff --git a/pkg/database/incidents.sql.go b/pkg/database/incidents.sql.go index a894f1e..6e1491f 100644 --- a/pkg/database/incidents.sql.go +++ b/pkg/database/incidents.sql.go @@ -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, diff --git a/pkg/database/models.go b/pkg/database/models.go index 2f470b6..0d80a21 100644 --- a/pkg/database/models.go +++ b/pkg/database/models.go @@ -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"` diff --git a/pkg/incidents/incident.go b/pkg/incidents/incident.go index e8d2f7a..14ae1cb 100644 --- a/pkg/incidents/incident.go +++ b/pkg/incidents/incident.go @@ -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"` diff --git a/pkg/incidents/incstore/store.go b/pkg/incidents/incstore/store.go index 9113690..81ce14d 100644 --- a/pkg/incidents/incstore/store.go +++ b/pkg/incidents/incstore/store.go @@ -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, diff --git a/pkg/pb/stillbox.pb.go b/pkg/pb/stillbox.pb.go index f473933..2742bc8 100644 --- a/pkg/pb/stillbox.pb.go +++ b/pkg/pb/stillbox.pb.go @@ -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 diff --git a/sql/postgres/migrations/001_initial.up.sql b/sql/postgres/migrations/001_initial.up.sql index 2a3995d..ea77bf7 100644 --- a/sql/postgres/migrations/001_initial.up.sql +++ b/sql/postgres/migrations/001_initial.up.sql @@ -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, diff --git a/sql/postgres/queries/incidents.sql b/sql/postgres/queries/incidents.sql index 0bc1e89..9dca9f6 100644 --- a/sql/postgres/queries/incidents.sql +++ b/sql/postgres/queries/incidents.sql @@ -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,