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:
Viktor Torstensson 2026-02-27 18:59:52 +01:00
parent fb5b0af8d8
commit 08a1a7421f
No known key found for this signature in database
GPG key ID: 961CC8259AE675D4
2 changed files with 63 additions and 0 deletions

View file

@ -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

View file

@ -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)