Skip to content

Dual-Database Design

TrustRAG supports two database backends via Rust feature flags.

PostgreSQL Mode (--features postgres)

Used in server deployments. Provides:

  • pgvector for vector similarity search
  • pg_trgm for trigram-based text similarity
  • Full SQL feature set
  • Multi-user concurrent access

SQLite Mode (--features desktop)

Used in desktop self-contained apps. Provides:

  • FTS5 for full-text search
  • Zero-configuration embedded database
  • Single-file storage
  • No external dependencies

Compatibility Layer

The db::compat module handles cross-database differences:

ConcernPostgreSQLSQLite
UUIDsNative UUID typeTEXT with string parsing
Booleanstrue/false1/0
TimestampsNOW()datetime('now')
OFFSETStandardRequires explicit syntax
RETURNINGFull supportLimited support

Migration Files

  • backend/migrations/ — PostgreSQL migrations (SQLx)
  • backend/migrations_sqlite/init.sql — SQLite schema initialization

Released under the Apache 2.0 License.