Database Setup
Configure the database for Ops Atlas.
PostgreSQL (Recommended)
Docker
yaml
services:
db:
image: postgres:15-alpine
environment:
POSTGRES_DB: opsatlas
POSTGRES_USER: opsatlas
POSTGRES_PASSWORD: ${DB_PASSWORD}
volumes:
- postgres_data:/var/lib/postgresql/dataExternal PostgreSQL
bash
# Create database
psql -U postgres << 'SQL'
CREATE DATABASE opsatlas;
CREATE USER opsatlas WITH ENCRYPTED PASSWORD 'your-password';
GRANT ALL PRIVILEGES ON DATABASE opsatlas TO opsatlas;
SQLConnection string:
DATABASE_URL=postgres://opsatlas:your-password@db-host:5432/opsatlasSQLite (Development Only)
For quick local development:
bash
DATABASE_URL=sqlite:./data/opsatlas.dbWARNING
SQLite is not recommended for production use.
Connection Pooling
For high-traffic deployments, use PgBouncer:
yaml
services:
pgbouncer:
image: edoburu/pgbouncer
environment:
DATABASE_URL: postgres://user:pass@db:5432/opsatlas
POOL_MODE: transaction
MAX_CLIENT_CONN: 100Migrations
Migrations run automatically on startup. To run manually:
bash
# Check status
ops-atlas db status
# Run migrations
ops-atlas db migrate
# Rollback
ops-atlas db rollbackBackup & Restore
bash
# Backup
pg_dump -U opsatlas opsatlas > backup_$(date +%Y%m%d).sql
# Restore
psql -U opsatlas opsatlas < backup_20250101.sql