// PART 08
Database model
The schema is one contract between features and data. This page maps its domains, names the owner of every declaration, and points at the tables an operator actually touches.
Domains
The schema is organized in feature domains, declared in the botschema crate
(#1497 — every Diesel table!/joinable! lives there and nowhere else):
| Domain | Tables |
|---|---|
people |
44 |
core |
34 |
billing |
25 |
compliance |
18 |
mail |
15 |
workspaces |
14 |
social |
13 |
attendant |
11 |
agents |
10 |
meet, research |
9 each |
autotask, video, tickets, email_integration |
6–8 each |
| others (analytics, calendar, canvas, channels, cloud, consent, dashboards, database_manager, desktop, drive, goals, integrations, learn, marketplace, memory, project, runs, security, weba) | 1–7 each |
Totals at the time the generated reference was produced: 307 tables · 3592 columns · 35 domains · 189 join edges. Regenerate rather than re-count:
python3 scripts/gen_schema_reference.py
Who owns the schema
table!/joinable!/allow_tables_to_appear_in_same_query!macros live only inbotschema. Feature crates re-export (pub use botschema::<table>;) — copying a table into a feature crate is caught in review.- A
#[derive(Queryable)]struct and itstable!must never disagree on a column’s type. - Schema changes go through a migration, never through an
ALTERin code (see Migrations).
The tables an operator actually touches
| Table | Why it matters |
|---|---|
bots |
one row per bot; is_active is the kill switch; org_id must never be NULL |
user_sessions |
user ↔ bot sessions; the audit trail’s spine |
message_history |
the conversation record; the largest table in most deployments |
bot_channels |
channel bindings; is_active per channel |
llm_metrics |
one row per model call; the cost and outage evidence |
ops_request_metrics |
request counters flushed every 30 s; prunable |
ops_deploy_markers |
one row per boot with version, commit, build date |
__diesel_schema_migrations |
which migrations ran, and when |
bot_domains |
custom domain → bot mappings |
rbac_user_groups |
group membership that resolves roles |
Data models beyond the main database
- Vibe project databases — every Vibe project kind owns a dedicated
PostgreSQL database per environment (
bot_{branch}_{bot}production,bot_{branch}_{bot}_devfor the dev twin); the_devsuffix is reserved. Promotion copies code only; databases are never touched by promote/rollback. - Vector collections — knowledge lives in Qdrant, one collection per
.gbkbfolder, records carrying path/type/bucket/tags. - Object storage — bots and files live in OtterIO buckets; the database references them, it does not contain them.
A restore that loses any of these three in sync with the others is not a restore: the drill checks the database, and Drive is mirrored separately.