Implement new budget with transaction to be able to satisfy not null columns

This commit is contained in:
2021-12-11 20:19:52 +00:00
parent 935499e3a8
commit 40a299141d
3 changed files with 40 additions and 0 deletions

View File

@ -102,3 +102,19 @@ func (q *Queries) GetFirstActivity(ctx context.Context, budgetID uuid.UUID) (tim
err := row.Scan(&min_date)
return min_date, err
}
const setInflowCategory = `-- name: SetInflowCategory :exec
UPDATE budgets
SET income_category_id = $1
WHERE budgets.id = $2
`
type SetInflowCategoryParams struct {
IncomeCategoryID uuid.UUID
ID uuid.UUID
}
func (q *Queries) SetInflowCategory(ctx context.Context, arg SetInflowCategoryParams) error {
_, err := q.db.ExecContext(ctx, setInflowCategory, arg.IncomeCategoryID, arg.ID)
return err
}