add worknote created time
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-03-25 06:55:01 +11:00
parent 6389f53ae3
commit e722ebe3f4
3 changed files with 17 additions and 2 deletions

View File

@@ -0,0 +1,9 @@
-- +goose Up
-- +goose StatementBegin
ALTER TABLE worknotes ADD COLUMN created_at DATETIME DEFAULT CURRENT_TIMESTAMP;
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
ALTER TABLE worknotes DROP COLUMN created_at;
-- +goose StatementEnd

View File

@@ -46,4 +46,5 @@ type Worknote struct {
ID int64
IncidentNumber string
Note sql.NullString
CreatedAt sql.NullTime
}

View File

@@ -136,7 +136,7 @@ INSERT into worknotes (
) VALUES(
?, ?
)
RETURNING id, incident_number, note
RETURNING id, incident_number, note, created_at
`
type CreateWorkNoteParams struct {
@@ -147,7 +147,12 @@ type CreateWorkNoteParams struct {
func (q *Queries) CreateWorkNote(ctx context.Context, arg CreateWorkNoteParams) (Worknote, error) {
row := q.db.QueryRowContext(ctx, createWorkNote, arg.IncidentNumber, arg.Note)
var i Worknote
err := row.Scan(&i.ID, &i.IncidentNumber, &i.Note)
err := row.Scan(
&i.ID,
&i.IncidentNumber,
&i.Note,
&i.CreatedAt,
)
return i, err
}