Database Requirements
Vestauth requires PostgreSQL 12 or higher for storing agent identities and public keys.Supported Databases
- Local PostgreSQL - For development and testing
- Managed PostgreSQL - Production-ready options:
- Supabase
- AWS RDS
- Google Cloud SQL
- Azure Database for PostgreSQL
- DigitalOcean Managed Databases
- Heroku Postgres
Database Schema
Vestauth uses two main tables to store agent data:agents Table
Stores agent identity information.
Indexes:
- Unique index on
uid(index_agents_on_uid)
public_jwks Table
Stores agent public keys (JSON Web Keys).
Indexes:
- Index on
agent_id(index_public_jwks_on_agent_id) - Unique index on
kid(index_public_jwks_on_kid)
agent_idreferencesagents.id
Database Commands
Create Database
Create thevestauth_production database:
- Connects to PostgreSQL’s maintenance database (
postgres) - Checks if
vestauth_productionexists - Creates the database if it doesn’t exist
The database name is extracted from the
DATABASE_URL environment variable.For example, postgres://localhost/vestauth_production creates a database named vestauth_production.Run Migrations
Apply database schema migrations:knex_migrations table.
Drop Database
Database Connection
Connection URL Format
Vestauth uses standard PostgreSQL connection URLs:Local PostgreSQL
For local development:.env
- Host:
localhost - Port:
5432(default) - Database:
vestauth_production - User: Current OS user
- No password (peer authentication)
Managed PostgreSQL
For production with Supabase:.env
.env
Connection with SSL
Vestauth automatically configures SSL for database connections:Migrations
Vestauth uses Knex.js for database migrations.Migration Files
Migrations are located insrc/server/db/migration/:
Migration Structure
Each migration file exportsup and down functions:
20260223204000_create_agents_table.js
Migration Tracking
Knex creates aknex_migrations table to track which migrations have been applied:
Database Administration
Direct Database Access
Connect to your database usingpsql:
Local PostgreSQL
Managed PostgreSQL
Query Agent Data
View all agents:Backup and Restore
Backup your database:Troubleshooting
Connection Issues
If you seemissing DATABASE_URL error:
- Verify
.envfile exists and containsDATABASE_URL - Check the URL format is correct
- Ensure PostgreSQL is running:
pg_isready
invalid DATABASE_URL error:
- Check for typos in the connection string
- Verify the URL follows the format:
postgresql://user:pass@host:port/db
Migration Errors
If migrations fail:Permission Errors
If you see permission denied errors:- Ensure your PostgreSQL user has sufficient privileges
- Grant necessary permissions:
SSL Connection Issues
For managed databases requiring strict SSL: Modifysrc/lib/helpers/dbMigrate.js to include CA certificate:
Production Recommendations
1
Use Connection Pooling
Most managed PostgreSQL services provide connection pooling (e.g., Supabase Pooler, PgBouncer).Use the pooled connection URL:
2
Enable Automated Backups
Configure daily automated backups in your PostgreSQL provider:
- Supabase: Automatic daily backups
- AWS RDS: Configure automated snapshots
- DigitalOcean: Enable daily backups
3
Monitor Database Performance
Set up monitoring for:
- Connection count
- Query performance
- Storage usage
- Replication lag (if applicable)
4
Configure Resource Limits
Set appropriate resource limits based on expected load:
- Connection pool size
- Memory allocation
- CPU allocation