Skip to content

Database Configuration

Bridge Payments supports multiple database systems with automatic schema management and migrations.

Supported Databases

DatabaseStatusUse Case
PostgreSQL✅ RecommendedProduction, high traffic
MySQL✅ SupportedProduction, compatibility
SQLite✅ SupportedDevelopment, testing
LibSQL✅ SupportedEdge deployments (Turso)
Neon✅ SupportedServerless PostgreSQL
PlanetScale✅ SupportedServerless MySQL

Configuration

PostgreSQL

bash
# Standard PostgreSQL
DATABASE_URL=postgresql://user:password@localhost:5432/bridge_payments

# With SSL
DATABASE_URL=postgresql://user:password@host:5432/bridge_payments?sslmode=require

# Neon (Serverless PostgreSQL)
DATABASE_URL=postgresql://user:[email protected]/bridge_payments?sslmode=require

MySQL

bash
# Standard MySQL
DATABASE_URL=mysql://user:password@localhost:3306/bridge_payments

# PlanetScale (Serverless MySQL)
DATABASE_URL=mysql://user:[email protected]/bridge_payments?ssl={"rejectUnauthorized":true}

SQLite

bash
# Local file
DATABASE_URL=sqlite://./bridge_payments.db

# In-memory (testing only)
DATABASE_URL=sqlite://:memory:

LibSQL (Turso)

bash
# Turso (Edge SQLite)
DATABASE_URL=libsql://your-database.turso.io
DATABASE_AUTH_TOKEN=your_auth_token

Database Schema

Bridge Payments uses the Native Payments standard schema, an open-source payment database structure created by Pubflow.

Schema Overview

The Native Payments schema includes tables for:

  • Users & Organizations - User accounts and organization management
  • Payment Providers - Multi-provider support (Stripe, PayPal, Authorize.net)
  • Customers - Customer records (authenticated users and guests)
  • Payment Methods - Saved payment methods with tokenization
  • Payments - Payment transactions with detailed tracking
  • Subscriptions - Recurring billing and subscription management
  • Orders & Invoices - Order processing and invoice generation
  • Addresses - Billing and shipping addresses
  • Webhooks - Event tracking and webhook logs
  • Coupons - Discount codes and promotions

View Complete Schema

The complete database schema is available in the Native Payments repository:

PostgreSQL Schema:

https://github.com/pubflow/native-payments/blob/main/postgresql/schema.sql

MySQL Schema:

https://github.com/pubflow/native-payments/blob/main/mysql/schema.sql

SQLite Schema:

https://github.com/pubflow/native-payments/blob/main/sqlite/schema.sql

Key Features

  • Multi-Provider Support - Unified schema for all payment providers
  • Guest Checkout - Full support for guest payments and subscriptions
  • Organization Support - Multi-tenant architecture
  • Comprehensive Indexing - Optimized for performance
  • Flexible Pricing - Subtotal, tax, and discount tracking
  • Audit Trail - Complete payment history and tracking

Connection Pooling

Configure connection pooling for optimal performance:

bash
# PostgreSQL / MySQL
DATABASE_POOL_MIN=2
DATABASE_POOL_MAX=10
DATABASE_TIMEOUT=30000

Best Practices

1. Choose the Right Database

  • PostgreSQL: Best for production with high traffic and complex queries
  • LibSQL/Turso: Best for edge deployments and global distribution
  • MySQL: Good for compatibility and wide hosting support
  • SQLite: Perfect for development and testing

2. Use SSL in Production

Always enable SSL for production databases:

bash
# PostgreSQL with SSL
DATABASE_URL=postgresql://user:password@host:5432/db?sslmode=require

# MySQL with SSL
DATABASE_URL=mysql://user:password@host:3306/db?ssl={"rejectUnauthorized":true}

3. Enable Connection Pooling

Configure appropriate pool sizes based on your traffic:

bash
DATABASE_POOL_MIN=2
DATABASE_POOL_MAX=10

4. Monitor Performance

  • Track query performance
  • Monitor connection pool usage
  • Set up alerts for slow queries
  • Use database-specific monitoring tools

5. Regular Backups

Set up automated backups for your production database. Most cloud providers (Neon, PlanetScale, Turso) offer automated backup solutions.

6. Use Environment Variables

Never hardcode database credentials. Always use environment variables:

bash
DATABASE_URL=postgresql://user:password@host:5432/bridge_payments

Next Steps