Skip to main content

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
Connection Pooling:
  • Efficient connection management via node-postgres
  • Configurable pool size and timeout settings
  • Automatic connection recycling
Native Type System:
  • Boolean, timestamp with timezone, JSONB, arrays
  • Custom types and enums
  • Full-text search capabilities

Drizzle ORM Integration

DeployStack uses the node-postgres driver for optimal PostgreSQL performance:

Working with Query Results

PostgreSQL operations return result objects with specific properties:

Standard Patterns

Delete Operations:
Update Operations:
Counting Affected Rows:

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: Example Table Definition:

Adding New Tables

When adding new tables, follow this pattern:
  1. Create table definition in src/db/schema-tables/[group].ts
  2. Generate migration using npm run db:generate
  3. Review and apply migration
Example: Adding a “notifications” table:

Migration System

Migration Directory

PostgreSQL migrations are stored in:

Migration SQL Structure

PostgreSQL migrations use standard PostgreSQL SQL syntax:

Generating Migrations

The migration generator analyzes your schema changes and creates appropriate SQL migration files.

Applying Migrations

Migrations are automatically applied on server startup:
You can also apply migrations manually:

Environment Configuration

Required Environment Variables

SSL Configuration

For production deployments with SSL:
This enables SSL with rejectUnauthorized: false for self-signed certificates. For production, configure proper SSL certificates.

Docker Compose Example

Development Workflow

Local Development Setup

  1. Install PostgreSQL:
  2. Create Database:
  3. Configure Environment:
  4. Setup Database:

Testing with PostgreSQL

Advanced PostgreSQL Features

JSONB Support

PostgreSQL’s JSONB type provides efficient JSON storage with indexing:
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.