The fee-transfer arm of the transaction search, as a view.
Same motivation as depositTransactionView (see schema/deposit.ts): the
inline 12-arm UNION serialises past the RDS Proxy 16KB parse limit and pins
connections. Behind a view the runtime statement is a short SELECT.
Two sub-arms, one per side of the transfer:
DEBIT — audience: the source customer. Projects the source wallet /
ledger account / customer, with the target side as other_wallet_*.
CREDIT — audience: the target customer. Mirrored.
Filtering is entirely the shared transactionScalarConditions, applied on
this view's own projected columns because a view takes no parameters. A fee
transfer has TWO customers, so customer_id is what scopes each side: it is
source_customer_id on the debit arm and target_customer_id on the credit arm,
so each side sees only its own row. Both arms project the same
receipt ->> 'id' as signature.
bankIds never reaches this arm — buildTransactionSelects skips it when
bankIds is set, since fee transfers never touch a bank rail (bank_id /
bank_transaction_id are unconditionally NULL).
securityInvoker is required: every underlying table has RLS enabled, and
without it the view would run with the owner's row visibility.
The fee-transfer arm of the transaction search, as a view.
Same motivation as
depositTransactionView(seeschema/deposit.ts): the inline 12-arm UNION serialises past the RDS Proxy 16KB parse limit and pins connections. Behind a view the runtime statement is a short SELECT.Two sub-arms, one per side of the transfer:
Filtering is entirely the shared
transactionScalarConditions, applied on this view's own projected columns because a view takes no parameters. A fee transfer has TWO customers, socustomer_idis what scopes each side: it is source_customer_id on the debit arm and target_customer_id on the credit arm, so each side sees only its own row. Both arms project the samereceipt ->> 'id'assignature.bankIdsnever reaches this arm —buildTransactionSelectsskips it whenbankIdsis set, since fee transfers never touch a bank rail (bank_id / bank_transaction_id are unconditionally NULL).securityInvokeris required: every underlying table has RLS enabled, and without it the view would run with the owner's row visibility.