Implement new budget with transaction to be able to satisfy not null columns
This commit is contained in:
@ -22,5 +22,24 @@ func (s *Database) NewBudget(context context.Context, name string, userID uuid.U
|
||||
return nil, err
|
||||
}
|
||||
|
||||
group, err := q.CreateCategoryGroup(context, CreateCategoryGroupParams{
|
||||
Name: "Inflow",
|
||||
BudgetID: budget.ID,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cat, err := q.CreateCategory(context, CreateCategoryParams{
|
||||
Name: "Ready to assign",
|
||||
CategoryGroupID: group.ID,
|
||||
})
|
||||
|
||||
q.SetInflowCategory(context, SetInflowCategoryParams{
|
||||
IncomeCategoryID: cat.ID,
|
||||
ID: budget.ID,
|
||||
})
|
||||
tx.Commit()
|
||||
|
||||
return &budget, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user