DB Access
Runtime connections
Section titled “Runtime connections”The API builds runtime database URLs in apps/api/src/config.ts.
It supports:
- explicit
POSTGRES_URLandREDIS_URL - or separate host/user/password/port env variables
Local development
Section titled “Local development”Start local services:
docker compose up -d db redisThen run:
pnpm dev:apiDrizzle tooling
Section titled “Drizzle tooling”Useful root commands:
pnpm db:generate:apipnpm db:migrate:apipnpm db:studio:apipnpm db:push:apipnpm db:pull:api
Direct PostgreSQL access
Section titled “Direct PostgreSQL access”When POSTGRES_URL is set:
psql "$POSTGRES_URL"When using split env values:
psql "postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:$POSTGRES_PORT/$POSTGRES_DB"Redis access
Section titled “Redis access”If REDIS_URL is set:
redis-cli -u "$REDIS_URL"If using split env values:
redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" -a "$REDIS_PASSWORD"Partitioned tables
Section titled “Partitioned tables”The base SQL script creates the partitioned parent tables only.
Files:
packages/database/src/utils/sql_scripts/create_items.sqlpackages/database/src/utils/sql_scripts/examples/create_items_partitions.example.sqlpackages/database/src/utils/sql_scripts/create_actions_events.sqlpackages/database/src/utils/sql_scripts/examples/create_actions_events_partitions.example.sql
Use the example files only as templates. Real item partitions should be created per network/domain, and real action/event partitions should be created per network/action.