Skip to content

Database

Nyravio uses PostgreSQL 16 with the pgvector extension for data storage and vector search.

The default compose.yaml includes a managed PostgreSQL instance. No external database setup is required for typical deployments.

db:
image: pgvector/pgvector:pg16
environment:
POSTGRES_DB: ${POSTGRES_DB:-nyravio}
POSTGRES_USER: ${POSTGRES_USER:-nyravio}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
volumes:
- pgdata:/var/lib/postgresql/data

Data is stored in the pgdata Docker volume and persists across container restarts.

Variable Default Description
POSTGRES_DB nyravio Database name
POSTGRES_USER nyravio Database user
POSTGRES_PASSWORD (required) Database password

To use an external PostgreSQL server:

  • PostgreSQL 16 (major version must match)
  • pgvector extension installed and available
  • A dedicated database and user for Nyravio
  1. Install pgvector on your PostgreSQL server. Refer to the pgvector installation guide.

  2. Create the database and user:

    CREATE USER nyravio WITH PASSWORD 'your-secure-password';
    CREATE DATABASE nyravio OWNER nyravio;
  3. Update your .env with the external connection details.

  4. Modify compose.yaml — remove or comment out the db service and the pgdata volume. Update the nyravio service environment:

    services:
    nyravio:
    environment:
    SPRING_DATASOURCE_URL: jdbc:postgresql://your-db-host:5432/nyravio
    SPRING_DATASOURCE_USERNAME: nyravio
    SPRING_DATASOURCE_PASSWORD: your-secure-password
  5. Start Nyravio — Flyway migrations run automatically on first startup and create all required tables and extensions.

Nyravio uses Flyway for database schema management.

  • Migrations run automatically on application startup
  • Migrations are forward-only — there is no automatic rollback
  • The application will not start if any migration fails
  • Hibernate DDL auto-generation is disabled (ddl-auto=none)

If a migration fails:

  1. Check application logs for the specific error
  2. Restore from backup if needed (see Recovery)
  3. Report the issue with the migration error message

The default connection pool settings (HikariCP):

Setting Default
Maximum pool size 30
Minimum idle 10
Connection timeout 30,000 ms
Max lifetime 1,800,000 ms (30 min)

These defaults are suitable for most deployments.

Database backups are critical. See Backup for the complete procedure including integrity verification.