@cfxlabsinc/b2b-services
    Preparing search index...

    Module @cfxlabsinc/db

    db

    Houses database migrations, types and configuration for running a local PostgreSQL instance.

    Boots an in-process pglite (no Docker), applies all migrations, seeds it, and serves it over the Postgres wire protocol on port 54332 — the same port the old container used, so DATABASE_URL is unchanged.

    It runs in the foreground: leave it in a terminal and press Ctrl-C to shut it down. There is no background container to forget to stop.

    pnpm exec nx run db:start
    

    Because pglite holds no state on disk, every start is a clean reset — migrations and seed are re-applied from scratch on each boot. To pick up a new migration, Ctrl-C and start again. (This is why there is no separate reset or stop target.)

    Seed scripts (seed/*.sql) are applied automatically on every start. To boot without them:

    pnpm exec nx run db:start:skip-seed
    

    This will generate a blank migration file within the migrations directory.

    pnpm exec nx run db:migrate-new <name>
    
    pnpm exec nx run db:migrate-up
    
    pnpm exec nx run db:migrate-down
    
    pnpm exec nx run db:migrate-status
    
    pnpm exec nx run db:migrate-dump
    

    To add seed data to the database, you can create .sql scripts within the seed directory.

    Running the start target on this project will automatically seed the database using these seed scripts.

    This data will only be inserted into the local instance.

    The pulumi/ directory is a standalone Pulumi program (cfx-db) that owns the RDS PostgreSQL primary and its read replicas per stack.

    createDatabase provisions:

    • a primary aws.rds.Instance (encrypted, Performance Insights on, deletion protection + final snapshot in prod)
    • readReplicaCount replica instances via replicateSourceDb, all sharing the primary's VPC security groups / parameter group

    Stack outputs published for consumers (Doppler, other Pulumi stacks via StackReference):

    • primaryEndpoint, primaryAddress, primaryPort, primaryArn, primaryIdentifier
    • replicaEndpoints, replicaAddresses, replicaArns, replicaIdentifiers

    Replica addresses should be passed as readReplicaSqlClients into createDrizzle so reads round-robin across them while writes/transactions stay on the primary.

    Non-secret knobs live in Pulumi.dev.yaml / Pulumi.prod.yaml: engine version, instance class, storage, multi-AZ, backup retention, subnet group, parameter group, security groups, replica count. masterPassword is a Pulumi secret — set it per-stack before the first deploy:

    cd packages/db/pulumi
    pulumi stack select dev
    pulumi config set --secret masterPassword <generated-password>
    pnpm exec nx run db:pulumi-preview        # dev (default)
    pnpm exec nx run db:pulumi-preview:prod
    pnpm exec nx run db:pulumi-up # dev
    pnpm exec nx run db:pulumi-up:prod

    The existing primary database is currently managed outside this package. Before running pulumi up for real, import the current RDS instance into cfx-db/<stack> (either via pulumi import or the import: resource option) so this stack adopts it instead of provisioning a duplicate.

    Classes

    DbHelper

    Type Aliases

    AchFileMetadata
    AchInstructionData
    AfWithdrawalProductName
    B2bDatabase
    B2bPgTransaction
    BackofficeWalletData
    BankDashboardTheme
    BankId
    BankVendor
    ChainData
    ChainRuntime
    ConcreteProductName
    DbOrderByCriterion
    DbTimestampCriteria
    DepositProductName
    EscrowTransferHistoryEntry
    EscrowTransferMetadata
    EscrowTransferRequestStatus
    EscrowTransferStatus
    Fees
    ForeignSwiftWireInstructionData
    InsertAchFile
    InsertCustomerApiKey
    InsertCustomerApiPlan
    InsertCustomerSlackBotChannel
    InsertCustomerSlackBotInstallation
    InsertEntityProductBlock
    InsertEscrowTransfer
    InsertEscrowTransferRequest
    InsertProductQuote
    InsertQuilttConnection
    InsertRewardInventory
    InsertRewardLedger
    InsertShortUrl
    InsertSlackBotInstallation
    InsertSolanaAccountTransaction
    InsertSwapQuote
    InsertVictorAccount
    InsertVictorProgram
    InsertVirtualAccount
    InsertWithdrawalQuote
    Matcher
    MatcherCriteria
    MatcherField
    NonBankVendor
    PinnedMatcherCriteria
    ProductName
    ProductQuoteData
    ProductRouteVersionData
    QuilttAccountData
    RtpInstructionData
    RuleCondition
    RuleGroup
    SelectAchBatch
    SelectAchFile
    SelectAdminDashboardPermission
    SelectAdminDashboardRole
    SelectAdminDashboardRolePermission
    SelectAdminDashboardUser
    SelectAdminDashboardUserActivity
    SelectBackofficeWallet
    SelectBank
    SelectBankInternalTransfer
    SelectBankTransaction
    SelectChain
    SelectCustomer
    SelectCustomerApiKey
    SelectCustomerApiPlan
    SelectCustomerDashboardUser
    SelectCustomerDashboardUserActivity
    SelectCustomerParent
    SelectCustomerSlackBotChannel
    SelectCustomerSlackBotInstallation
    SelectDashboardCustomerUser
    SelectDeposit
    SelectDepositBankMemo
    SelectDepositQuote
    SelectDepositStatusUpdate
    SelectEntityDocument
    SelectEntityProductBlock
    SelectEscrowTransfer
    SelectEscrowTransferRequest
    SelectFedAchDirectoryRecord
    SelectFedParticipantDirectoryRecord
    SelectFeeTransfer
    SelectFeeTransferStatusUpdate
    SelectGirasolCard
    SelectGirasolCardAccount
    SelectGirasolCardClearing
    SelectGirasolCardTransaction
    SelectGirasolCardTransactionStatusUpdate
    SelectGirasolClearingRecord
    SelectIdentity
    SelectLedgerAccount
    SelectLedgerAccountTransfer
    SelectLedgerAccountTransferStatusUpdate
    SelectLedgerAccountWithdrawal
    SelectLedgerAccountWithdrawalStatusUpdate
    SelectManualMint
    SelectMetcapToken
    SelectMetcapWireTransaction
    SelectOrganization
    SelectPaymentInstrument
    SelectPaymentInstrumentBlacklist
    SelectProduct
    SelectProductActivationRule
    SelectProductActivationRuleVersion
    SelectProductFeeRule
    SelectProductFeeRuleVersion
    SelectProductLimitRule
    SelectProductLimitRuleVersion
    SelectProductQuote
    SelectProductRoute
    SelectProductRouteVersion
    SelectProductVendor
    SelectProductVendorVersion
    SelectQuilttConnection
    SelectRedemption
    SelectRedemptionStatusUpdate
    SelectRelatedPerson
    SelectRewardClaim
    SelectRewardEventConfig
    SelectRewardInventory
    SelectRewardLedger
    SelectShortUrl
    SelectSlackBotInstallation
    SelectSolanaAccountTransaction
    SelectSolanaNonce
    SelectSolanaTransaction
    SelectSwap
    SelectSwapQuote
    SelectSwapStatusUpdate
    SelectToken
    SelectTransactionMetadata
    SelectTransactionMetadataFile
    SelectUsCashDepositRetailer
    SelectUtilaSweepWallet
    SelectVictorAccount
    SelectVictorProgram
    SelectVirtualAccount
    SelectVirtualAccountProvider
    SelectWireBatch
    SelectWireEmail
    SelectWireFile
    SelectWithdrawal
    SelectWithdrawalQuote
    SelectWithdrawalStatusUpdate
    SourceWalletType
    Speed
    SwiftWireInstructionData
    TokenData
    UsdSwiftWireInstructionData
    UsWireInstructionData
    Vendor
    WildcardProductName
    WireEmailParsed
    WireWithdrawalPurpose
    WithdrawalProductName

    Variables

    achBatchTable
    achFileTable
    admin
    adminDashboardPermissionTable
    adminDashboardRolePermissionTable
    adminDashboardRoleTable
    adminDashboardUserActivityTable
    adminDashboardUserTable
    AF_WITHDRAWAL_PRODUCT_NAMES
    b2b
    backofficeWalletTable
    BANK_IDS
    bankInternalTransferTable
    bankTable
    bankTransactionTable
    chainTable
    CONCRETE_PRODUCT_NAMES
    customerApiKeyTable
    customerApiPlanTable
    customerDashboardUserActivityTable
    customerDashboardUserTable
    customerParentTable
    customerSlackBotChannel
    customerSlackBotInstallationTable
    customerTable
    dashboardCustomerUserTable
    DEPOSIT_PRODUCT_NAMES
    depositBankMemoTable
    depositQuoteTable
    depositStatusUpdateTable
    depositTable
    entityDocumentTable
    entityProductBlockTable
    ESCROW_TRANSFER_REQUEST_STATUSES
    escrowTransferRequestTable
    escrowTransferTable
    fedAchDirectoryTable
    fedParticipantDirectoryTable
    feeTransferStatusUpdateTable
    feeTransferTable
    girasolCardAccountTable
    girasolCardTable
    girasolCardTransactionStatusUpdateTable
    girasolCardTransactionTable
    girasolClearingBatchTable
    girasolClearingRecordTable
    identityTable
    ledgerAccountTable
    ledgerAccountTransferStatusUpdateTable
    ledgerAccountTransferTable
    ledgerAccountWithdrawalStatusUpdateTable
    ledgerAccountWithdrawalTable
    manualMintTable
    metcapTokenTable
    metcapWireTransactionTable
    organizationTable
    paymentInstrumentBlacklistTable
    paymentInstrumentTable
    PRODUCT_NAMES
    productActivationRuleTable
    productActivationRuleVersionTable
    productFeeRuleTable
    productFeeRuleVersionTable
    productLimitRuleTable
    productLimitRuleVersionTable
    productQuoteTable
    productRouteTable
    productRouteVersionTable
    productTable
    productVendorTable
    productVendorVersionTable
    quilttConnectionTable
    redemptionStatusUpdateTable
    redemptionTable
    relatedPersonTable
    rewardClaimTable
    rewardEventConfigTable
    rewardInventoryTable
    rewardLedgerTable
    shortUrlTable
    slackBotInstallationTable
    solanaAccountTransactionTable
    solanaNoncePoolTable
    solanaTransactionTable
    swapQuoteTable
    swapStatusUpdateTable
    swapTable
    tokenTable
    transactionMetadataFileTable
    transactionMetadataTable
    usCashDepositRetailerTable
    utilaSweepWalletTable
    victorAccountTable
    victorProgramTable
    virtualAccountProviderTable
    virtualAccountTable
    WILDCARD_PRODUCT_NAMES
    wireBatchTable
    wireEmailTable
    wireFileTable
    WITHDRAWAL_PRODUCT_NAMES
    withdrawalQuoteTable
    withdrawalStatusUpdateTable
    withdrawalTable

    Functions

    bankSupportsRail
    caseOn
    caseWhen
    coalesce
    createDrizzle
    createIamRdsPasswordSigner
    createSqlClient
    dbOrderBy
    dbTimestampQuery
    isBankVendor
    isForeignKeyViolatedError
    isNotNullViolatedError
    isUniqueConstraintViolatedError
    nanoId
    vendorBankIdMismatch