Database Configuration
Deckyard supports multiple storage backends for your data.
Storage Options
Section titled “Storage Options”File-based Storage (Default)
Section titled “File-based Storage (Default)”By default, Deckyard uses JSON file-based storage. No additional configuration required.
Data locations:
- Presentations:
server/data/presentations/ - Uploads:
server/uploads/
This is ideal for:
- Local development
- Single-instance deployments
- Simple self-hosted setups
PostgreSQL
Section titled “PostgreSQL”For production deployments, PostgreSQL is recommended. It provides:
- Better performance at scale
- Multi-instance support
- Reliable data persistence
- Full-text search capabilities
PostgreSQL Setup
Section titled “PostgreSQL Setup”1. Enable PostgreSQL Mode
Section titled “1. Enable PostgreSQL Mode”Set the storage mode in your environment:
STORAGE_MODE=postgres2. Configure Connection
Section titled “2. Configure Connection”Using individual variables (recommended):
DATABASE_HOST=localhostDATABASE_PORT=5432DATABASE_NAME=deckyardDATABASE_USER=deckyardDATABASE_PASSWORD=your-secure-passwordUsing connection URL:
DATABASE_URL=postgres://deckyard:password@localhost:5432/deckyard3. SSL Configuration
Section titled “3. SSL Configuration”SSL is enabled by default for non-localhost connections.
# Disable SSL (e.g., for local Docker networks)DATABASE_SSL=false
# Allow self-signed certificates (e.g., managed database services)DATABASE_SSL_REJECT_UNAUTHORIZED=false4. Connection Pool
Section titled “4. Connection Pool”Configure the connection pool size:
DATABASE_POOL_MIN=2 # Minimum connections (default: 2)DATABASE_POOL_MAX=10 # Maximum connections (default: 10)Migrations
Section titled “Migrations”Deckyard uses Kysely for database migrations.
Running Migrations
Section titled “Running Migrations”Migrations run automatically on server startup when using PostgreSQL mode. You can also run them manually:
npm run db:migrateMigration Status
Section titled “Migration Status”Check which migrations have been applied:
npm run db:migrate:statusCreating New Migrations
Section titled “Creating New Migrations”For development, create a new migration:
npm run db:migrate:create migration-nameMigrating from File to PostgreSQL
Section titled “Migrating from File to PostgreSQL”If you’re upgrading from file-based storage to PostgreSQL:
1. Set Up PostgreSQL
Section titled “1. Set Up PostgreSQL”Create the database and run migrations:
STORAGE_MODE=postgres npm run db:migrate2. Migrate Existing Data
Section titled “2. Migrate Existing Data”Run the migration script:
npm run db:migrate:dataThis migrates:
- All presentations and their slides
- Tags and metadata
- Image library entries
- Published presentation data
3. Verify Migration
Section titled “3. Verify Migration”The script reports what was migrated. Verify your presentations are accessible before removing file-based data.
Dual-Write Mode
Section titled “Dual-Write Mode”For safe migration, you can enable dual-write mode:
# Write to both, read from file, compare resultsDUAL_WRITE_MODE=shadow
# Write to both, read from fileDUAL_WRITE_MODE=primary-file
# Write to both, read from PostgreSQLDUAL_WRITE_MODE=primary-postgresThis allows you to validate PostgreSQL behavior before fully switching.
Environment Variables Reference
Section titled “Environment Variables Reference”| Variable | Default | Description |
|---|---|---|
STORAGE_MODE | file | Storage backend: file or postgres |
DATABASE_HOST | localhost | PostgreSQL host |
DATABASE_PORT | 5432 | PostgreSQL port |
DATABASE_NAME | deckyard | Database name |
DATABASE_USER | deckyard | Database user |
DATABASE_PASSWORD | (empty) | Database password |
DATABASE_SSL | true (non-localhost) | Enable SSL |
DATABASE_SSL_REJECT_UNAUTHORIZED | true | Reject self-signed certs |
DATABASE_POOL_MIN | 2 | Minimum pool connections |
DATABASE_POOL_MAX | 10 | Maximum pool connections |
DUAL_WRITE_MODE | off | Migration dual-write mode |