Skip to main content

Overview

IronClaw supports two database backends:
  • PostgreSQL - Production-grade, requires a running server
  • libSQL - Embedded SQLite, zero dependencies, optional Turso cloud sync
The onboarding wizard helps you choose and configure either option. This guide covers manual configuration and advanced settings.

PostgreSQL

Requirements

  • PostgreSQL 15 or later
  • pgvector extension (required for embeddings)

Installation

# Install PostgreSQL and pgvector
brew install postgresql@15 pgvector

# Start PostgreSQL
brew services start postgresql@15

# Create database
createdb ironclaw

# Enable pgvector
psql ironclaw -c "CREATE EXTENSION IF NOT EXISTS vector;"

Configuration

Set the database URL in your environment or ~/.ironclaw/.env:
DATABASE_BACKEND=postgres
DATABASE_URL=postgres://user:password@localhost:5432/ironclaw
DATABASE_POOL_SIZE=10  # optional, default: 10
URL format:
postgres://username:password@host:port/database

Connection Pool

Configure the connection pool size:
DATABASE_POOL_SIZE=10  # Max concurrent connections
Recommendations:
  • Local development: 5-10 connections
  • Production: 20-50 connections (depends on workload)
  • Docker/VPS: Start with 10, adjust based on pg_stat_activity

SSL/TLS Configuration

Control SSL mode for PostgreSQL connections:
DATABASE_SSLMODE=prefer  # default
Options:
ModeBehavior
disableNever use TLS (plaintext only)
preferTry TLS first, fall back to plaintext
requireRequire TLS; fail if unavailable
Recommendations:
  • Local PostgreSQL: disable (no TLS needed)
  • Managed databases (Neon, Supabase, RDS): prefer or require
  • VPS/self-hosted: prefer (default, works everywhere)

Migrations

Migrations run automatically on first connection. To run manually:
ironclaw onboard  # Prompts to run migrations
Or apply with refinery CLI:
cargo install refinery_cli
refinery migrate -e DATABASE_URL -p migrations/

Cloud Providers

Neon provides serverless Postgres with automatic scaling.
DATABASE_URL=postgres://user:password@ep-xxx.region.aws.neon.tech/ironclaw?sslmode=require
pgvector is pre-installed. Set DATABASE_SSLMODE=require.
Supabase includes Postgres with pgvector.
DATABASE_URL=postgres://postgres:password@db.xxx.supabase.co:5432/postgres
Enable pgvector in SQL Editor:
CREATE EXTENSION IF NOT EXISTS vector;
Railway provides managed Postgres.
DATABASE_URL=${{Postgres.DATABASE_URL}}  # Railway variable
Install pgvector via Railway’s Postgres plugin settings.
RDS for PostgreSQL with pgvector.
DATABASE_URL=postgres://user:password@instance.region.rds.amazonaws.com:5432/ironclaw
DATABASE_SSLMODE=require
Enable pgvector:
CREATE EXTENSION IF NOT EXISTS vector;

Troubleshooting

Error: pgvector extension not foundSolution:Then enable in your database:
CREATE EXTENSION IF NOT EXISTS vector;
Error: PostgreSQL 14 detected. IronClaw requires PostgreSQL 15 or laterSolution: Upgrade PostgreSQL:
Error: connection refused or could not connect to serverCheck PostgreSQL is running:
# macOS
brew services list | grep postgresql

# Linux
systemctl status postgresql

# Docker
docker ps | grep postgres
Check port:
lsof -i :5432  # Should show postgres
Check pg_hba.conf if connecting remotely.
Error: password authentication failedCheck password:
psql -U username -d ironclaw  # Test connection
Reset password:
ALTER USER username WITH PASSWORD 'newpassword';

libSQL (Embedded)

Overview

libSQL is an embedded SQLite database with optional Turso cloud sync. No external database server required. Benefits:
  • Zero dependencies
  • Single file storage
  • Automatic migrations
  • Optional remote sync

Local Setup

DATABASE_BACKEND=libsql
LIBSQL_PATH=~/.ironclaw/ironclaw.db  # default
The database file is created automatically on first run.

Turso Cloud Sync

Turso provides remote replicas for libSQL databases. Setup:
  1. Create a Turso database:
    turso db create ironclaw
    
  2. Get connection details:
    turso db show ironclaw
    
  3. Create an auth token:
    turso db tokens create ironclaw
    
  4. Configure IronClaw:
    DATABASE_BACKEND=libsql
    LIBSQL_PATH=~/.ironclaw/ironclaw.db
    LIBSQL_URL=libsql://your-db.turso.io
    LIBSQL_AUTH_TOKEN=your-token
    
How it works:
  • Local file (LIBSQL_PATH) is the primary database
  • Changes sync to the remote replica (LIBSQL_URL)
  • Other instances can read from the remote replica

Configuration Options

VariableDescriptionDefault
DATABASE_BACKENDBackend typepostgres
LIBSQL_PATHLocal database file~/.ironclaw/ironclaw.db
LIBSQL_URLTurso remote URL (optional)-
LIBSQL_AUTH_TOKENTurso auth token (required if URL is set)-

Migrations

Migrations run automatically on first connection (idempotent CREATE IF NOT EXISTS).

Limitations

  • Concurrency: SQLite uses file-level locking (fine for single-user, not ideal for high-concurrency)
  • Vector search: Uses JSON instead of native vector types (slower than pgvector)
  • Backups: Copy the .db file (or use Turso cloud backups)

When to Use libSQL

Good for:
  • Personal use / single-user
  • Development / testing
  • Lightweight deployments
  • Portable installations
Use PostgreSQL if:
  • Multiple concurrent users
  • High-throughput workloads
  • Large-scale vector search
  • Production deployments

Switching Backends

To switch from PostgreSQL to libSQL (or vice versa):
  1. Export data (if needed):
    # PostgreSQL: pg_dump
    pg_dump ironclaw > backup.sql
    
  2. Change configuration:
    # Edit ~/.ironclaw/.env
    DATABASE_BACKEND=libsql
    LIBSQL_PATH=~/.ironclaw/ironclaw.db
    
  3. Re-run onboarding:
    ironclaw onboard
    
  4. Migrations run automatically on first connection.
Switching backends creates a fresh database. Export/import data manually if needed.

Environment Variables

PostgreSQL

VariableDescriptionDefault
DATABASE_BACKENDBackend type (postgres or libsql)postgres
DATABASE_URLPostgreSQL connection URL-
DATABASE_POOL_SIZEMax connections in pool10
DATABASE_SSLMODESSL mode (disable, prefer, require)prefer

libSQL

VariableDescriptionDefault
DATABASE_BACKENDBackend typepostgres
LIBSQL_PATHLocal database file~/.ironclaw/ironclaw.db
LIBSQL_URLTurso remote URL (optional)-
LIBSQL_AUTH_TOKENTurso auth token-

Backups

PostgreSQL

# Backup
pg_dump ironclaw > backup.sql

# Restore
psql ironclaw < backup.sql

libSQL

# Backup (copy file)
cp ~/.ironclaw/ironclaw.db ~/.ironclaw/ironclaw.db.backup

# Restore
cp ~/.ironclaw/ironclaw.db.backup ~/.ironclaw/ironclaw.db
Turso cloud: Automatic backups via Turso dashboard.