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

    Module @cfxlabsinc/b2b-db-schema

    db

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

    This will start a local PostgreSQL Docker container, run all migrations against it, and seed it:

    pnpm exec nx run db:start
    

    This will wipe the local database, re-run all migrations and seed the database:

    pnpm exec nx run db:reset
    

    This will explicitly just seed the local database. This will rarely need to be run. You'll more likely want to run reset during development.

    pnpm exec nx run db:seed
    
    pnpm exec nx run db:stop
    

    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 or reset targets 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

    AfWithdrawalProductName
    B2bDatabase
    B2bPgTransaction
    BankId
    BankVendor
    ConcreteProductName
    DbOrderByCriterion
    DbTimestampCriteria
    DepositProductName
    FeeItem
    Fees
    InsertAchFile
    InsertCustomerApiKey
    InsertCustomerSlackBotChannel
    InsertCustomerSlackBotInstallation
    InsertEntityProductBlock
    InsertProductQuote
    InsertQuilttConnection
    InsertRewardLedger
    InsertSlackBotInstallation
    InsertSolanaAccountTransaction
    InsertSwapQuote
    InsertVirtualAccount
    InsertWithdrawalQuote
    LimitItem
    Matcher
    MatcherCriteria
    MatcherField
    NonBankVendor
    PinnedMatcherCriteria
    ProductName
    ProductQuoteData
    ProductRouteVersionData
    QuilttAccountData
    RuleCondition
    RuleGroup
    SelectAchBatch
    SelectAchFile
    SelectAdminDashboardPermission
    SelectAdminDashboardRole
    SelectAdminDashboardRolePermission
    SelectAdminDashboardUser
    SelectAdminDashboardUserActivity
    SelectBank
    SelectBankInternalTransfer
    SelectBankTransaction
    SelectCustomer
    SelectCustomerApiKey
    SelectCustomerDashboardUser
    SelectCustomerDashboardUserActivity
    SelectCustomerParent
    SelectCustomerSlackBotChannel
    SelectCustomerSlackBotInstallation
    SelectDashboardCustomerUser
    SelectDeposit
    SelectDepositBankMemo
    SelectDepositQuote
    SelectDepositStatusUpdate
    SelectEntityProductBlock
    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
    SelectProductConfig
    SelectProductFeeConfig
    SelectProductFeeRule
    SelectProductFeeRuleVersion
    SelectProductLimitConfig
    SelectProductLimitRule
    SelectProductLimitRuleVersion
    SelectProductQuote
    SelectProductRoute
    SelectProductRouteVersion
    SelectProductVendor
    SelectProductVendorVersion
    SelectQuilttConnection
    SelectRedemption
    SelectRedemptionStatusUpdate
    SelectRewardClaim
    SelectRewardEventConfig
    SelectRewardLedger
    SelectSlackBotInstallation
    SelectSolanaAccountTransaction
    SelectSolanaNonce
    SelectSolanaTransaction
    SelectSwap
    SelectSwapQuote
    SelectSwapStatusUpdate
    SelectTransactionMetadata
    SelectTransactionMetadataFile
    SelectUsCashDepositRetailer
    SelectUtilaWallet
    SelectVirtualAccount
    SelectWireBatch
    SelectWireFile
    SelectWithdrawal
    SelectWithdrawalQuote
    SelectWithdrawalStatusUpdate
    SourceWalletType
    Speed
    Vendor
    WildcardProductName
    WireWithdrawalPurpose
    WithdrawalProductName

    Variables

    achBatchTable
    achFileTable
    admin
    adminDashboardPermissionTable
    adminDashboardRolePermissionTable
    adminDashboardRoleTable
    adminDashboardUserActivityTable
    adminDashboardUserTable
    AF_WITHDRAWAL_PRODUCT_NAMES
    b2b
    BANK_IDS
    bankInternalTransferTable
    bankTable
    bankTransactionTable
    CONCRETE_PRODUCT_NAMES
    customerApiKeyTable
    customerDashboardUserActivityTable
    customerDashboardUserTable
    customerParentTable
    customerSlackBotChannel
    customerSlackBotInstallationTable
    customerTable
    dashboardCustomerUserTable
    DEPOSIT_PRODUCT_NAMES
    depositBankMemoTable
    depositQuoteTable
    depositStatusUpdateTable
    depositTable
    entityProductBlockTable
    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
    productConfigTable
    productFeeConfigTable
    productFeeRuleTable
    productFeeRuleVersionTable
    productLimitConfigTable
    productLimitRuleTable
    productLimitRuleVersionTable
    productQuoteTable
    productRouteTable
    productRouteVersionTable
    productTable
    productVendorTable
    productVendorVersionTable
    quilttConnectionTable
    redemptionStatusUpdateTable
    redemptionTable
    rewardClaimTable
    rewardEventConfigTable
    rewardLedgerTable
    slackBotInstallationTable
    solanaAccountTransactionTable
    solanaNoncePoolTable
    solanaTransactionTable
    swapQuoteTable
    swapStatusUpdateTable
    swapTable
    transactionMetadataFileTable
    transactionMetadataTable
    usCashDepositRetailerTable
    utilaWalletTable
    virtualAccountTable
    WILDCARD_PRODUCT_NAMES
    wireBatchTable
    wireFileTable
    WITHDRAWAL_PRODUCT_NAMES
    withdrawalQuoteTable
    withdrawalStatusUpdateTable
    withdrawalTable

    Functions

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