Add transfer_id

This commit is contained in:
Jan Bader 2022-01-09 20:47:43 +00:00
parent 2f3e4bc748
commit 951e827d20
3 changed files with 11 additions and 2 deletions

View File

@ -64,6 +64,7 @@ type Transaction struct {
AccountID uuid.UUID AccountID uuid.UUID
CategoryID uuid.NullUUID CategoryID uuid.NullUUID
PayeeID uuid.NullUUID PayeeID uuid.NullUUID
TransferID uuid.NullUUID
} }
type TransactionsByMonth struct { type TransactionsByMonth struct {

View File

@ -0,0 +1,6 @@
-- +goose Up
ALTER TABLE transactions ADD COLUMN
transfer_id uuid NULL REFERENCES transactions (id);
-- +goose Down
ALTER TABLE transactions DROP COLUMN transfer_id;

View File

@ -14,7 +14,7 @@ const createTransaction = `-- name: CreateTransaction :one
INSERT INTO transactions INSERT INTO transactions
(date, memo, amount, account_id, payee_id, category_id) (date, memo, amount, account_id, payee_id, category_id)
VALUES ($1, $2, $3, $4, $5, $6) VALUES ($1, $2, $3, $4, $5, $6)
RETURNING id, date, memo, amount, account_id, category_id, payee_id RETURNING id, date, memo, amount, account_id, category_id, payee_id, transfer_id
` `
type CreateTransactionParams struct { type CreateTransactionParams struct {
@ -44,6 +44,7 @@ func (q *Queries) CreateTransaction(ctx context.Context, arg CreateTransactionPa
&i.AccountID, &i.AccountID,
&i.CategoryID, &i.CategoryID,
&i.PayeeID, &i.PayeeID,
&i.TransferID,
) )
return i, err return i, err
} }
@ -74,7 +75,7 @@ func (q *Queries) DeleteTransaction(ctx context.Context, id uuid.UUID) error {
} }
const getTransaction = `-- name: GetTransaction :one const getTransaction = `-- name: GetTransaction :one
SELECT id, date, memo, amount, account_id, category_id, payee_id FROM transactions SELECT id, date, memo, amount, account_id, category_id, payee_id, transfer_id FROM transactions
WHERE id = $1 WHERE id = $1
` `
@ -89,6 +90,7 @@ func (q *Queries) GetTransaction(ctx context.Context, id uuid.UUID) (Transaction
&i.AccountID, &i.AccountID,
&i.CategoryID, &i.CategoryID,
&i.PayeeID, &i.PayeeID,
&i.TransferID,
) )
return i, err return i, err
} }