mirror of
https://github.com/lightninglabs/lightning-terminal.git
synced 2026-08-13 12:33:36 +02:00
sqlcmig6: add new queries to the sqlcmig6 package
Add the ListAllAccountInvoices & ListAllAccountPayments queries to the sqlcmig6 package, to mimic the sqlc queries present before the kvdb to sql migration is added to prod.
This commit is contained in:
parent
93b9dec9b1
commit
2780d40223
2 changed files with 63 additions and 0 deletions
|
|
@ -253,6 +253,67 @@ func (q *Queries) ListAccountPayments(ctx context.Context, accountID int64) ([]A
|
|||
return items, nil
|
||||
}
|
||||
|
||||
const listAllAccountInvoices = `-- name: ListAllAccountInvoices :many
|
||||
SELECT account_id, hash
|
||||
FROM account_invoices
|
||||
`
|
||||
|
||||
func (q *Queries) ListAllAccountInvoices(ctx context.Context) ([]AccountInvoice, error) {
|
||||
rows, err := q.db.QueryContext(ctx, listAllAccountInvoices)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []AccountInvoice
|
||||
for rows.Next() {
|
||||
var i AccountInvoice
|
||||
if err := rows.Scan(&i.AccountID, &i.Hash); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const listAllAccountPayments = `-- name: ListAllAccountPayments :many
|
||||
SELECT account_id, hash, status, full_amount_msat
|
||||
FROM account_payments
|
||||
`
|
||||
|
||||
func (q *Queries) ListAllAccountPayments(ctx context.Context) ([]AccountPayment, error) {
|
||||
rows, err := q.db.QueryContext(ctx, listAllAccountPayments)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []AccountPayment
|
||||
for rows.Next() {
|
||||
var i AccountPayment
|
||||
if err := rows.Scan(
|
||||
&i.AccountID,
|
||||
&i.Hash,
|
||||
&i.Status,
|
||||
&i.FullAmountMsat,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const listAllAccounts = `-- name: ListAllAccounts :many
|
||||
SELECT id, alias, label, type, initial_balance_msat, current_balance_msat, last_updated, expiration
|
||||
FROM accounts
|
||||
|
|
|
|||
|
|
@ -54,6 +54,8 @@ type Querier interface {
|
|||
InsertSessionPrivacyFlag(ctx context.Context, arg InsertSessionPrivacyFlagParams) error
|
||||
ListAccountInvoices(ctx context.Context, accountID int64) ([]AccountInvoice, error)
|
||||
ListAccountPayments(ctx context.Context, accountID int64) ([]AccountPayment, error)
|
||||
ListAllAccountInvoices(ctx context.Context) ([]AccountInvoice, error)
|
||||
ListAllAccountPayments(ctx context.Context) ([]AccountPayment, error)
|
||||
ListAllAccounts(ctx context.Context) ([]Account, error)
|
||||
ListAllKVStoresRecords(ctx context.Context) ([]Kvstore, error)
|
||||
ListSessions(ctx context.Context) ([]Session, error)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue