Add group_id
This commit is contained in:
parent
951e827d20
commit
beff7afcf7
@ -64,7 +64,7 @@ type Transaction struct {
|
||||
AccountID uuid.UUID
|
||||
CategoryID uuid.NullUUID
|
||||
PayeeID uuid.NullUUID
|
||||
TransferID uuid.NullUUID
|
||||
GroupID uuid.NullUUID
|
||||
}
|
||||
|
||||
type TransactionsByMonth struct {
|
||||
|
@ -4,8 +4,8 @@ WHERE id = $1;
|
||||
|
||||
-- name: CreateTransaction :one
|
||||
INSERT INTO transactions
|
||||
(date, memo, amount, account_id, payee_id, category_id)
|
||||
VALUES ($1, $2, $3, $4, $5, $6)
|
||||
(date, memo, amount, account_id, payee_id, category_id, group_id)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
||||
RETURNING *;
|
||||
|
||||
-- name: UpdateTransaction :exec
|
||||
|
@ -1,6 +0,0 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE transactions ADD COLUMN
|
||||
transfer_id uuid NULL REFERENCES transactions (id);
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE transactions DROP COLUMN transfer_id;
|
6
postgres/schema/20220109_214000_add-group-id.sql
Normal file
6
postgres/schema/20220109_214000_add-group-id.sql
Normal file
@ -0,0 +1,6 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE transactions ADD COLUMN
|
||||
group_id uuid NULL;
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE transactions DROP COLUMN group_id;
|
@ -12,9 +12,9 @@ import (
|
||||
|
||||
const createTransaction = `-- name: CreateTransaction :one
|
||||
INSERT INTO transactions
|
||||
(date, memo, amount, account_id, payee_id, category_id)
|
||||
VALUES ($1, $2, $3, $4, $5, $6)
|
||||
RETURNING id, date, memo, amount, account_id, category_id, payee_id, transfer_id
|
||||
(date, memo, amount, account_id, payee_id, category_id, group_id)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
||||
RETURNING id, date, memo, amount, account_id, category_id, payee_id, group_id
|
||||
`
|
||||
|
||||
type CreateTransactionParams struct {
|
||||
@ -24,6 +24,7 @@ type CreateTransactionParams struct {
|
||||
AccountID uuid.UUID
|
||||
PayeeID uuid.NullUUID
|
||||
CategoryID uuid.NullUUID
|
||||
GroupID uuid.NullUUID
|
||||
}
|
||||
|
||||
func (q *Queries) CreateTransaction(ctx context.Context, arg CreateTransactionParams) (Transaction, error) {
|
||||
@ -34,6 +35,7 @@ func (q *Queries) CreateTransaction(ctx context.Context, arg CreateTransactionPa
|
||||
arg.AccountID,
|
||||
arg.PayeeID,
|
||||
arg.CategoryID,
|
||||
arg.GroupID,
|
||||
)
|
||||
var i Transaction
|
||||
err := row.Scan(
|
||||
@ -44,7 +46,7 @@ func (q *Queries) CreateTransaction(ctx context.Context, arg CreateTransactionPa
|
||||
&i.AccountID,
|
||||
&i.CategoryID,
|
||||
&i.PayeeID,
|
||||
&i.TransferID,
|
||||
&i.GroupID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@ -75,7 +77,7 @@ func (q *Queries) DeleteTransaction(ctx context.Context, id uuid.UUID) error {
|
||||
}
|
||||
|
||||
const getTransaction = `-- name: GetTransaction :one
|
||||
SELECT id, date, memo, amount, account_id, category_id, payee_id, transfer_id FROM transactions
|
||||
SELECT id, date, memo, amount, account_id, category_id, payee_id, group_id FROM transactions
|
||||
WHERE id = $1
|
||||
`
|
||||
|
||||
@ -90,7 +92,7 @@ func (q *Queries) GetTransaction(ctx context.Context, id uuid.UUID) (Transaction
|
||||
&i.AccountID,
|
||||
&i.CategoryID,
|
||||
&i.PayeeID,
|
||||
&i.TransferID,
|
||||
&i.GroupID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user