diff --git a/accounts/store_sql.go b/accounts/store_sql.go index 830f1658..2fc6d229 100644 --- a/accounts/store_sql.go +++ b/accounts/store_sql.go @@ -49,6 +49,9 @@ type SQLQueries interface { UpdateAccountBalance(ctx context.Context, arg sqlc.UpdateAccountBalanceParams) (int64, error) UpdateAccountExpiry(ctx context.Context, arg sqlc.UpdateAccountExpiryParams) (int64, error) UpdateAccountLastUpdate(ctx context.Context, arg sqlc.UpdateAccountLastUpdateParams) (int64, error) + // UpdateAccountAliasForTests is a query intended only for testing + // purposes, to change the account alias. + UpdateAccountAliasForTests(ctx context.Context, arg sqlc.UpdateAccountAliasForTestsParams) (int64, error) UpsertAccountPayment(ctx context.Context, arg sqlc.UpsertAccountPaymentParams) error GetAccountInvoice(ctx context.Context, arg sqlc.GetAccountInvoiceParams) (sqlc.AccountInvoice, error) } diff --git a/db/sqlc/accounts.sql.go b/db/sqlc/accounts.sql.go index f6b3fc81..33334dbc 100644 --- a/db/sqlc/accounts.sql.go +++ b/db/sqlc/accounts.sql.go @@ -313,6 +313,26 @@ func (q *Queries) SetAccountIndex(ctx context.Context, arg SetAccountIndexParams return err } +const updateAccountAliasForTests = `-- name: UpdateAccountAliasForTests :one +UPDATE accounts +SET alias = $1 +WHERE id = $2 + RETURNING id +` + +type UpdateAccountAliasForTestsParams struct { + Alias int64 + ID int64 +} + +// NOTE: This query is only intended for testing purposes. +func (q *Queries) UpdateAccountAliasForTests(ctx context.Context, arg UpdateAccountAliasForTestsParams) (int64, error) { + row := q.db.QueryRowContext(ctx, updateAccountAliasForTests, arg.Alias, arg.ID) + var id int64 + err := row.Scan(&id) + return id, err +} + const updateAccountBalance = `-- name: UpdateAccountBalance :one UPDATE accounts SET current_balance_msat = $1 diff --git a/db/sqlc/querier.go b/db/sqlc/querier.go index 4ff08707..3e261503 100644 --- a/db/sqlc/querier.go +++ b/db/sqlc/querier.go @@ -67,6 +67,8 @@ type Querier interface { SetSessionGroupID(ctx context.Context, arg SetSessionGroupIDParams) error SetSessionRemotePublicKey(ctx context.Context, arg SetSessionRemotePublicKeyParams) error SetSessionRevokedAt(ctx context.Context, arg SetSessionRevokedAtParams) error + // NOTE: This query is only intended for testing purposes. + UpdateAccountAliasForTests(ctx context.Context, arg UpdateAccountAliasForTestsParams) (int64, error) UpdateAccountBalance(ctx context.Context, arg UpdateAccountBalanceParams) (int64, error) UpdateAccountExpiry(ctx context.Context, arg UpdateAccountExpiryParams) (int64, error) UpdateAccountLastUpdate(ctx context.Context, arg UpdateAccountLastUpdateParams) (int64, error) diff --git a/db/sqlc/queries/accounts.sql b/db/sqlc/queries/accounts.sql index 9c23c8c4..3be5ccd5 100644 --- a/db/sqlc/queries/accounts.sql +++ b/db/sqlc/queries/accounts.sql @@ -25,6 +25,13 @@ RETURNING id; INSERT INTO account_invoices (account_id, hash) VALUES ($1, $2); +-- name: UpdateAccountAliasForTests :one +-- NOTE: This query is only intended for testing purposes. +UPDATE accounts +SET alias = $1 +WHERE id = $2 + RETURNING id; + -- name: DeleteAccountPayment :exec DELETE FROM account_payments WHERE hash = $1