Database¶
Each environment gets an Aurora PostgreSQL Serverless v2 cluster with IAM authentication (no passwords). The database auto-pauses after 4 hours of inactivity to save costs. First connection after pause takes ~30 seconds to wake up.
Database Roles¶
Four roles are created automatically:
| Role | Purpose |
|---|---|
inspect_admin |
Migrations (rds_superuser) |
inspect_app |
API read/write |
inspect_app_ro |
Read-only access |
middleman |
LLM proxy model config reads |
Connecting¶
Connect via IAM auth token (no passwords):
ENDPOINT=$(pulumi stack output database_endpoint)
TOKEN=$(aws rds generate-db-auth-token \
--hostname $ENDPOINT --port 5432 --region us-west-2 --username inspect_app)
PGPASSWORD="$TOKEN" psql "host=$ENDPOINT dbname=inspect user=inspect_app sslmode=require"
Running Migrations¶
Get the database URL from your infrastructure outputs:
Run migrations:
Creating a New Migration¶
After changing the SQLAlchemy models in hawk/core/db/models.py:
Test it round-trips cleanly:
Schema Conventions¶
- All tables have a
pkUUID primary key, andcreated_at/updated_attimestamps - All timestamps are timezone-aware and stored in UTC
- Model names are singular