Database

💾 Database

VexAI supports SQLite (default) and PostgreSQL as database backends, with optional AI embedding storage for semantic search.

SQLite (Default)

The default backend requires zero configuration and is ideal for single-server deployments.

  • WAL mode: enables concurrent read access without blocking
  • FTS5 full-text search: fast text indexing on messages
  • Embedding storage: separate message_embeddings table for AI vectors
  • Database file: data/vexai.db
💡 Tip

SQLite is production-ready for single-server bots. You only need PostgreSQL when handling multiple shards or very high traffic.

PostgreSQL

For production environments with high concurrency and advanced vector search.

  • Connection pooling: configurable min/max connections
  • tsvector full-text search: native PostgreSQL text indexing
  • pgvector: native vector column type with IVFFlat indexing for embeddings
  • Easy setup: use docker-compose.postgres.yml

Configuration (JSON)

{
  "database": {
    "type": "postgres",
    "url": "postgres://vexai:password@localhost:5432/vexai",
    "pool": { "min": 2, "max": 10 }
  }
}

Environment Variables

DATABASE_TYPE=postgres
DATABASE_URL=postgres://vexai:password@localhost:5432/vexai

Comparison

Feature SQLite PostgreSQL
SetupZero-configRequires server
Full-text searchFTS5tsvector
Embedding storageSeparate tablepgvector native
IndexingB-treeB-tree + IVFFlat
ConcurrencyWAL (single-writer)Full MVCC
Connection poolingN/ABuilt-in
Best forDevelopment, single serverProduction, high traffic

Live Migration

Seamlessly migrate between backends without downtime.

  • /migrate to-postgres: streams all data from SQLite to PostgreSQL with a live progress bar
  • /migrate status: shows the current backend and row counts per table
⚠️ Warning

Back up your SQLite database before migrating. Copy data/vexai.db to a safe location first.

Database Tables

Sequential migrations (v1–v8) create the following tables:

Table Purpose
logsStructured bot activity logs
cron_jobsScheduled task definitions
usersUser records
warningsUser warning history
remindersTime-based reminders
auto_rolesRoles assigned on join
welcome_configWelcome message settings
model_overridesPer-user LLM model overrides
conversations / conversation_messagesPersistent conversation history
semantic_memoriesFTS5-powered memory store
messages / message_revisionsDiscord message mirror + audit trail
message_embeddingsAI embedding vectors

Embedding Providers

VexAI supports multiple embedding providers for generating semantic vectors.

Provider Default Model Dimensions Notes
builtinXenova/all-MiniLM-L6-v2384In-process ONNX, offline, zero cost
openaitext-embedding-3-small1536Best quality
openrouteropenai/text-embedding-3-small1536Many models, one key
localnomic-embed-text768Any OpenAI-compatible endpoint

Configuration

{
  "embeddings": {
    "enabled": true,
    "provider": "builtin",
    "model": "Xenova/all-MiniLM-L6-v2",
    "dimensions": 384,
    "batchSize": 50
  }
}