Overview
DeployStack uses PostgreSQL as its database backend, providing enterprise-grade reliability with ACID compliance, advanced features, and horizontal scalability through read replicas and partitioning.Setup Instructions: For initial PostgreSQL configuration, see the Database Setup Guide.
Technical Architecture
Enterprise PostgreSQL Features
ACID Compliance:- Full transactional support with rollback capabilities
- Multi-version concurrency control (MVCC)
- Point-in-time recovery and continuous archiving
- Efficient connection management via
node-postgres - Configurable pool size and timeout settings
- Automatic connection recycling
- Boolean, timestamp with timezone, JSONB, arrays
- Custom types and enums
- Full-text search capabilities
Drizzle ORM Integration
DeployStack uses thenode-postgres driver for optimal PostgreSQL performance:
Working with Query Results
PostgreSQL operations return result objects with specific properties:Standard Patterns
Delete Operations:Schema Architecture
Schema Structure
DeployStack uses a modular schema structure with PostgreSQL-native types: File Structure:PostgreSQL Type System
DeployStack leverages PostgreSQL’s native type system: Data Types:| Type | PostgreSQL Implementation | Example |
|---|---|---|
| Boolean | boolean('col') | email_verified: boolean('email_verified') |
| Timestamp | timestamp('col', { withTimezone: true }) | created_at: timestamp('created_at', { withTimezone: true }) |
| Default Now | .defaultNow() | created_at: timestamp('created_at').defaultNow() |
| Text/String | text('col') | name: text('name') |
| JSONB | jsonb('col') | metadata: jsonb('metadata') |
| Table Builder | pgTable('name', { ... }) | export const users = pgTable('users', { ... }) |
Adding New Tables
When adding new tables, follow this pattern:- Create table definition in
src/db/schema-tables/[group].ts - Generate migration using
npm run db:generate - Review and apply migration
Migration System
Migration Directory
PostgreSQL migrations are stored in:Migration SQL Structure
PostgreSQL migrations use standard PostgreSQL SQL syntax:Generating Migrations
Applying Migrations
Migrations are automatically applied on server startup:Environment Configuration
Required Environment Variables
SSL Configuration
For production deployments with SSL:rejectUnauthorized: false for self-signed certificates. For production, configure proper SSL certificates.
Docker Compose Example
Development Workflow
Local Development Setup
-
Install PostgreSQL:
-
Create Database:
-
Configure Environment:
-
Setup Database:
Testing with PostgreSQL
Advanced PostgreSQL Features
JSONB Support
PostgreSQL’s JSONB type provides efficient JSON storage with indexing:Full-Text Search
PostgreSQL provides powerful full-text search capabilities:Advanced Indexing
Connection Pool Tuning
Query Optimization
Using Explain
Query Builder Performance
Backup and Recovery
Backup Strategies
Restore Database
Monitoring and Maintenance
Database Statistics
Vacuum and Analyze
For more information about database management in DeployStack, see the Database Management Guide.

