diff --git a/db/migrations/20250324195310_worknote_update.sql b/db/migrations/20250324195310_worknote_update.sql new file mode 100644 index 0000000..c21aa47 --- /dev/null +++ b/db/migrations/20250324195310_worknote_update.sql @@ -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 diff --git a/db/queries/models.go b/db/queries/models.go index f4baf6b..9dd5524 100644 --- a/db/queries/models.go +++ b/db/queries/models.go @@ -46,4 +46,5 @@ type Worknote struct { ID int64 IncidentNumber string Note sql.NullString + CreatedAt sql.NullTime } diff --git a/db/queries/query.sql.go b/db/queries/query.sql.go index 5b73dc3..c569d33 100644 --- a/db/queries/query.sql.go +++ b/db/queries/query.sql.go @@ -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 }