Use goose for migrations

This commit is contained in:
2021-11-08 22:24:21 +00:00
parent cf1bc70103
commit 5de7d32c30
25 changed files with 134 additions and 145 deletions

View File

@ -20,7 +20,19 @@ type CreateBudgetParams struct {
}
func (q *Queries) CreateBudget(ctx context.Context, arg CreateBudgetParams) (Budget, error) {
row := q.db.QueryRow(ctx, createBudget, arg.ID, arg.Name)
row := q.db.QueryRowContext(ctx, createBudget, arg.ID, arg.Name)
var i Budget
err := row.Scan(&i.ID, &i.Name, &i.LastModification)
return i, err
}
const getBudget = `-- name: GetBudget :one
SELECT id, name, last_modification FROM budgets
WHERE id = $1
`
func (q *Queries) GetBudget(ctx context.Context, id string) (Budget, error) {
row := q.db.QueryRowContext(ctx, getBudget, id)
var i Budget
err := row.Scan(&i.ID, &i.Name, &i.LastModification)
return i, err
@ -33,7 +45,7 @@ WHERE user_budgets.user_id = $1
`
func (q *Queries) GetBudgetsForUser(ctx context.Context, userID string) ([]Budget, error) {
rows, err := q.db.Query(ctx, getBudgetsForUser, userID)
rows, err := q.db.QueryContext(ctx, getBudgetsForUser, userID)
if err != nil {
return nil, err
}
@ -46,6 +58,9 @@ func (q *Queries) GetBudgetsForUser(ctx context.Context, userID string) ([]Budge
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}