Database Configuration ​
Bridge Payments supports multiple database systems with automatic schema management and migrations.
Supported Databases ​
| Database | Status | Use Case |
|---|---|---|
| PostgreSQL | ✅ Recommended | Production, high traffic |
| MySQL | ✅ Supported | Production, compatibility |
| SQLite | ✅ Supported | Development, testing |
| LibSQL | ✅ Supported | Edge deployments (Turso) |
| Neon | ✅ Supported | Serverless PostgreSQL |
| PlanetScale | ✅ Supported | Serverless 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=requireMySQL ​
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_tokenDatabase 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.sqlMySQL Schema:
https://github.com/pubflow/native-payments/blob/main/mysql/schema.sqlSQLite Schema:
https://github.com/pubflow/native-payments/blob/main/sqlite/schema.sqlKey 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=30000Best 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=104. 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_paymentsNext Steps ​
- Environment Configuration - All environment variables
- Pubflow Integration - Connect to Flowless
- Provider Configuration - Configure payment providers