Database Schema
Hrida.ai keeps users, chats, files, knowledge bases, settings and everything else in one relational database: SQLite by default, or PostgreSQL when you set DATABASE_URL. Both use the same tables, created and upgraded by migrations when Hrida.ai starts.
Use this page to plan backups, write reports, or debug a deployment.
Change data through the UI or the API, not with SQL. Columns change between releases, and the application keeps related tables, caches and the vector store in step that a direct write would skip. Back up the database before any manual change.
Where the Database Lives
| Deployment | Location |
|---|---|
| Docker (SQLite) | /app/backend/data/hridaai.db inside the container, on the hrida-ai volume |
| Python / pip (SQLite) | hridaai.db in the data directory (DATA_DIR) |
| PostgreSQL | The database named in DATABASE_URL |
The data directory holds more than the database:
/app/backend/data
├── hridaai.db # the database (SQLite)
├── uploads/ # uploaded files
├── vector_db/ # the default vector store (ChromaDB)
└── cache/ # downloaded models and other cachesTo copy the SQLite database out of a running container:
docker cp hrida-ai:/app/backend/data/hridaai.db ./hridaai.dbOpen the copy, not the live file, with any SQLite client. For example, to list the tables:
sqlite3 ./hridaai.db ".tables"Conventions
- IDs are text, usually UUIDs.
configis the exception, with an integer ID. - Timestamps are Unix epoch integers. The unit depends on the table: seconds in most tables, nanoseconds in the channel, message, calendar, note and automation tables. Each table below says which.
- JSON columns store structured data:
TEXTin SQLite,JSONin PostgreSQL. - Columns are nullable unless marked
NOT NULL. - Ownership:
user_idrefers touser.id, but most tables don't declare it as a foreign key. - Sharing is stored in
access_grant, not in the shared resource's own row.
Tables at a Glance
Users & Access
| Table | Holds |
|---|---|
user | User profiles, roles and preferences |
auth | Sign-in credentials (password hashes) |
api_key | Personal API keys |
oauth_session | OAuth tokens from SSO sign-ins |
group | User groups and their permissions |
group_member | Group membership |
access_grant | Who may read or edit each shared resource |
usage_limit | Token and cost limits per user or group |
Chats
| Table | Holds |
|---|---|
chat | Conversations, with the full message tree |
chat_message | Chat messages as rows, for queries and analytics |
chat_file | Files attached in chats |
shared_chat | Snapshots behind share links |
folder | Chat folders |
tag | Chat tags |
feedback | Ratings and feedback on answers |
memory | Saved memories used for personalization |
Channels
| Table | Holds |
|---|---|
channel | Channels and direct-message groups |
channel_member | Channel membership and read state |
channel_file | Files posted in channels |
channel_webhook | Incoming webhooks that post to channels |
message | Channel messages and threads |
message_reaction | Reactions to channel messages |
Files & Knowledge
| Table | Holds |
|---|---|
file | Uploaded files and their metadata |
knowledge | Knowledge bases |
knowledge_file | Files in each knowledge base |
Models, Prompts, Tools & Skills
| Table | Holds |
|---|---|
model | Workspace models (presets on top of base models) |
model_pricing | Token prices per model, for cost reports |
prompt | Prompt templates (/ commands) |
prompt_history | Prompt versions |
tool | Tools (Python toolkits) |
function | Functions: filters, actions and pipes |
skill | Skills (Markdown instructions) |
skill_history | Skill versions |
office_skills_bundle | Uploaded Office skills bundles |
Notes, Calendar & Automations
| Table | Holds |
|---|---|
note | Notes |
pinned_note | Notes each user pinned |
calendar | Calendars |
calendar_event | Calendar events |
calendar_event_attendee | Event invitations and RSVPs |
automation | Scheduled automations |
automation_run | Automation run history |
Artifacts
| Table | Holds |
|---|---|
artifact | Artifacts (documents, decks, designs) and their content |
artifact_asset | Images and files used by artifacts |
artifact_comment | Comments on artifacts |
artifact_job | Background jobs that build or convert artifacts |
shared_artifact | Snapshots behind artifact share links |
Spaces, Projects & Boards
| Table | Holds |
|---|---|
space | Spaces: shared workspaces inside an agent catalog |
space_member | Space membership and roles |
project | Projects with their own instructions |
workcast_board | Task boards |
workcast_board_member | Board members (users or groups) |
workcast_task | Tasks on boards |
workcast_task_activity | Task change history |
Agent Builder & Workflows
| Table | Holds |
|---|---|
agent_workflow | Agent Builder workflows and their graphs |
workflow_version | Published workflow versions (snapshots) |
agent_lifecycle_event | Workflow lifecycle transitions (submit, approve, publish) |
approval_matrix | Approval stages required for a workflow |
approval_stage_record | Progress of each approval stage |
workflow_run | Workflow runs, with saved state for paused runs |
workflow_execution_log | Step-by-step log of each workflow run |
run_timeline | Timeline events streamed during a run |
workflow_trigger | Schedules, webhooks and events that start workflows |
workflow_test_case | Saved test inputs and expected outputs for workflows |
inbox_task | Human review tasks raised by workflows |
agent_skill | Agent skills: reusable agent definitions for workflows |
skill_execution_log | One row per agent-skill call, for analytics |
digital_employee | Digital employees (named agent roles) |
business_event | Business events published to workflows |
saga_definition | Multi-step sagas triggered by business events |
saga_instance | Running or finished sagas |
saga_step | Steps of each saga, with compensation state |
audit_log | Configuration changes to Agent Builder resources |
Agent Catalogs & Data Sources
| Table | Holds |
|---|---|
catalog | Agent catalogs: model providers, policies and settings |
catalog_secret | Encrypted secrets stored in a catalog |
catalog_quota | Monthly token, cost and run limits per catalog |
workflow_run_cost | Tokens and cost of each workflow run |
consumer_org | Consumer organizations in a catalog |
agent_datasource | Database connections for agents (data sources) |
datasource_session_token | Short-lived dsq_ tokens for data-source access from terminals |
datasource_query_log | Queries run against data sources |
incident_provider | Incident management integrations |
computer_token | Scoped cpk_ tokens for each user's Computer |
API Platform
| Table | Holds |
|---|---|
api_catalog | API catalogs |
api_space | API spaces inside a catalog |
api_space_member | API space membership |
api_definition | APIs: OpenAPI spec, upstream, auth and gateway policy |
api_definition_version | API versions (snapshots) |
api_lifecycle_event | API lifecycle transitions |
api_gateway | Gateways that serve published APIs |
api_environment | Environments (e.g. test, production) |
api_publication | Which APIs are published to which spaces |
api_consumer_key | Keys for API consumers, with quotas and IP rules |
api_protocol_mapper | SOAP/XML protocol mapping per operation |
api_message_mapper | Request and response transforms per operation |
api_gateway_call | Gateway call log |
api_gateway_call_capture | Captured request and response details for debugging |
api_gateway_call_rollup | Call statistics per time bucket |
api_gateway_call_archive | Archived call logs (per day) |
api_gateway_job | Locks and status of gateway background jobs |
api_alert_rule | Alert rules on API metrics |
api_alert_event | Fired and resolved API alerts |
api_assistant_chat | API assistant conversations |
api_assistant_chat_message | Messages in API assistant conversations |
Email, Messaging & Meetings
| Table | Holds |
|---|---|
email_account | Connected mailboxes (IMAP/SMTP, CalDAV) |
email_triage_cache | Triaged emails with summaries and drafts |
email_draft | Email drafts |
messaging_account | Connected messaging accounts |
messaging_message_cache | Received messages with summaries |
meeting_config | Meeting provider settings |
meeting_session | Meetings and their recordings |
meeting_note | Meeting transcripts, summaries and action items |
Administration & System
| Table | Holds |
|---|---|
config | Persistent admin settings |
admin_assistant_chat | Admin assistant conversations |
admin_assistant_chat_message | Messages in admin assistant conversations |
admin_assistant_action | Changes proposed and applied by the admin assistant |
Other Tables
| Table | Holds |
|---|---|
alembic_version | The current migration revision. Don't edit it. |
document_chunk | Vector embeddings, only when VECTOR_DB is pgvector or opengauss |
document, chatidtag | Legacy tables from early releases, kept by the migrations. No longer used. |
Tables outside the core set below are documented by their models in the Studio source, backend/hrida_ai_studio/models/.
Core Tables
The columns below are read from the application's data models. Constraints added only by migrations, such as some unique constraints, are listed under each table.
Users & Access
User
user: User profiles, roles and preferences. Timestamps are in seconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | String | PRIMARY KEY | Unique identifier |
email | String | — | User's email |
username | String(50) | — | Username (optional) |
role | String | — | User's role |
name | String | — | User's name |
profile_image_url | Text | — | Profile image path |
profile_banner_image_url | Text | — | Profile banner image path |
bio | Text | — | User's biography |
gender | Text | — | User's gender |
date_of_birth | Date | — | User's date of birth |
timezone | String | — | IANA time zone, e.g. Europe/Berlin |
presence_state | String | — | Presence shown to other users |
status_emoji | String | — | Custom status emoji |
status_message | Text | — | Custom status text |
status_expires_at | BigInteger | — | When the custom status clears |
info | JSON | — | Additional user info |
settings | JSON | — | User preferences |
oauth | JSON | — | Linked OAuth identities, per provider |
scim | JSON | — | SCIM provisioning data |
last_active_at | BigInteger | — | Last activity timestamp |
updated_at | BigInteger | — | Last update timestamp |
created_at | BigInteger | — | Creation timestamp |
- One-to-one with
auth(sameid). - API keys live in the
api_keytable, and linked OAuth identities in theoauthcolumn; both replaced earlier columns on this table. scimholds theexternalIdper identity provider from SCIM provisioning, for example{"okta": {"external_id": "def-456"}}. Lookups byexternalIdfall back to the OAuth identity when no SCIM entry matches.
Auth
auth: Sign-in credentials (password hashes).
| Column | Type | Constraints | Description |
|---|---|---|---|
id | String | PRIMARY KEY | Unique identifier |
email | String | — | User's email |
password | Text | — | Hashed password |
active | Boolean | — | Account status |
- One-to-one with
user(sameid).passwordis a hash, never the password itself.
API Key
api_key: Personal API keys. Timestamps are in seconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique identifier |
user_id | Text | NOT NULL | Owner of the key |
key | Text | NOT NULL, UNIQUE | The key value (sk-…) |
data | JSON | — | Additional key data |
expires_at | BigInteger | — | Expiry time (null: never) |
last_used_at | BigInteger | — | Last time the key authenticated a request |
created_at | BigInteger | NOT NULL | Creation timestamp |
updated_at | BigInteger | NOT NULL | Last update timestamp |
OAuth Session
oauth_session: OAuth tokens from SSO sign-ins. Timestamps are in seconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique session identifier |
user_id | Text | NOT NULL | Associated user |
provider | Text | NOT NULL | OAuth provider (e.g., 'google') |
token | Text | NOT NULL | OAuth session token |
expires_at | BigInteger | NOT NULL | Token expiration timestamp |
created_at | BigInteger | NOT NULL | Session creation timestamp |
updated_at | BigInteger | NOT NULL | Session last update timestamp |
tokenis a JSON string with the access, ID and refresh tokens. Indexed onuser_id,expires_atand (user_id,provider).
Group
group: User groups and their permissions. Timestamps are in seconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique identifier (UUID) |
user_id | Text | — | Group owner/creator |
name | Text | — | Group name |
description | Text | — | Group description |
data | JSON | — | Additional group data |
meta | JSON | — | Group metadata |
permissions | JSON | — | Permission configuration |
created_at | BigInteger | — | Creation timestamp |
updated_at | BigInteger | — | Last update timestamp |
Group Member
group_member: Group membership. Timestamps are in seconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique identifier (UUID) |
group_id | Text | FK → group.id (cascade), NOT NULL | Reference to the group |
user_id | Text | NOT NULL | Reference to the user |
created_at | BigInteger | — | Creation timestamp |
updated_at | BigInteger | — | Last update timestamp |
- Unique on (
group_id,user_id). Deleting a group deletes its members.
Access Grant
access_grant: Who may read or edit each shared resource. Timestamps are in seconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique identifier (UUID) |
resource_type | Text | NOT NULL | Type of resource (e.g., model, knowledge, tool) |
resource_id | Text | NOT NULL | ID of the specific resource |
principal_type | Text | NOT NULL | Type of grantee: user or group |
principal_id | Text | NOT NULL | ID of the user or group (or * for public) |
permission | Text | NOT NULL | Permission level: read or write |
created_at | BigInteger | NOT NULL | Grant creation timestamp |
- One row per grant, for every shareable resource:
resource_typeis for examplemodel,knowledge,tool,prompt,note,channel,file,skill,calendarorshared_chat. principal_typeisuserorgroup; ausergrant withprincipal_id*means public access.- Unique on (
resource_type,resource_id,principal_type,principal_id,permission), and indexed by resource and by principal.
Usage Limit
usage_limit: Token and cost limits per user or group. Timestamps are in seconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique identifier |
scope | Text | NOT NULL | user or group |
scope_id | Text | NOT NULL | The user or group ID |
limit_type | Text | NOT NULL | tokens or cost_usd |
limit_value | Numeric(18, 8) | NOT NULL | The limit |
period | Text | NOT NULL | daily or monthly |
hard_limit | Boolean | NOT NULL, default True | Block requests over the limit (False: warn only) |
alert_threshold_pct | Text | NOT NULL, default 80 | Percentage of the limit that triggers an alert (stored as text) |
created_at | BigInteger | NOT NULL | Creation timestamp |
updated_at | BigInteger | NOT NULL | Last update timestamp |
- Unique on (
scope,scope_id,limit_type,period). See Usage Limits.
Chats
Chat
chat: Conversations, with the full message tree. Timestamps are in seconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | String | PRIMARY KEY | Unique identifier (UUID) |
user_id | String | — | Owner of the chat |
title | Text | — | Chat title |
chat | JSON | — | Chat content and history |
created_at | BigInteger | — | Creation timestamp |
updated_at | BigInteger | — | Last update timestamp |
share_id | Text | UNIQUE | Sharing identifier |
archived | Boolean | default False | Archive status |
pinned | Boolean | default False | Pin status |
meta | JSON | default {} | Metadata including tags |
folder_id | Text | — | Parent folder ID |
tasks | JSON | — | Chat-level task/todo list used by agentic workflows |
summary | Text | — | Optional chat summary text |
last_read_at | BigInteger | — | Last read timestamp used for unread indicators |
chatholds the full conversation tree as JSON;chat_messageholds the same messages as rows for queries and analytics.tasksandsummaryback the task list and summary shown in agentic chats.last_read_atdrives the unread marker in the sidebar.share_idis theshared_chat.idof the chat's active share link.
Chat Message
chat_message: Chat messages as rows, for queries and analytics. Timestamps are in seconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Message ID |
chat_id | Text | FK → chat.id (cascade), NOT NULL, indexed | Chat the message belongs to |
user_id | Text | indexed | Owner of the chat |
role | Text | NOT NULL | user, assistant or system |
parent_id | Text | — | Previous message in the branch |
content | JSON | — | Message content: text or a list of content blocks |
output | JSON | — | Structured output items (reasoning, tool calls, …) |
model_id | Text | indexed | Model that wrote the message (assistant messages) |
files | JSON | — | Attachments |
sources | JSON | — | Citations and retrieved sources |
embeds | JSON | — | Embedded UI content |
done | Boolean | default True | Whether generation finished |
status_history | JSON | — | Status updates shown during generation |
error | JSON | — | Error details, if generation failed |
usage | JSON | — | Token counts and timing |
created_at | BigInteger | indexed | Creation timestamp |
updated_at | BigInteger | — | Last update timestamp |
- Indexed on (
chat_id,parent_id), (model_id,created_at) and (user_id,created_at). Deleting a chat deletes its messages.
Chat File
chat_file: Files attached in chats. Timestamps are in seconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique identifier (UUID) |
user_id | Text | NOT NULL | User associated with the file |
chat_id | Text | FK → chat.id (cascade), NOT NULL | Reference to the chat |
message_id | Text | — | Reference to associated message |
file_id | Text | FK → file.id (cascade), NOT NULL | Reference to the file |
created_at | BigInteger | NOT NULL | Creation timestamp |
updated_at | BigInteger | NOT NULL | Last update timestamp |
- Unique on (
chat_id,file_id). Lets Studio find a chat's files without reading every message, and stays consistent across nodes.
Shared Chat
shared_chat: Snapshots behind share links. Timestamps are in seconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Share token (UUID) used in /s/{id} URLs |
chat_id | Text | FK → chat.id (cascade), NOT NULL | Reference to the original chat |
user_id | Text | NOT NULL | User who created the share |
title | Text | — | Chat title at time of sharing |
chat | JSON | — | Snapshot of chat content at share time |
created_at | BigInteger | — | Share creation timestamp |
updated_at | BigInteger | — | Last re-snapshot timestamp |
- Each row is a snapshot of the chat when it was shared; Update and Copy Link refreshes it. Deleting the chat deletes the snapshot.
- Who may open a share link is stored in
access_grant(resource_type = 'shared_chat').
Folder
folder: Chat folders. Timestamps are in seconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique identifier (UUID) |
parent_id | Text | — | Parent folder ID for hierarchy |
user_id | Text | — | Owner of the folder |
name | Text | — | Folder name |
items | JSON | — | Folder contents |
meta | JSON | — | Folder metadata |
data | JSON | — | Additional folder data |
is_expanded | Boolean | default False | UI expansion state |
created_at | BigInteger | — | Creation timestamp |
updated_at | BigInteger | — | Last update timestamp |
- Folders nest through
parent_id; root folders have none.
Tag
tag: Chat tags.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | String | PRIMARY KEY (composite) | Normalized tag identifier (part of the primary key) |
name | String | — | Display name |
user_id | String | PRIMARY KEY (composite) | Tag owner (part of the primary key) |
meta | JSON | — | Tag metadata |
- The primary key is (
id,user_id): each user has their own tags.
Feedback
feedback: Ratings and feedback on answers. Timestamps are in seconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique identifier (UUID) |
user_id | Text | — | User who provided feedback |
version | BigInteger | default 0 | Feedback version number |
type | Text | — | Type of feedback |
data | JSON | — | Feedback data including ratings |
meta | JSON | — | Metadata (arena, chat_id, etc) |
snapshot | JSON | — | Associated chat snapshot |
created_at | BigInteger | — | Creation timestamp |
updated_at | BigInteger | — | Last update timestamp |
Memory
memory: Saved memories used for personalization. Timestamps are in seconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | String | PRIMARY KEY | Unique identifier (UUID) |
user_id | String | indexed | Memory owner |
content | Text | — | Memory content |
updated_at | BigInteger | — | Last update timestamp |
created_at | BigInteger | — | Creation timestamp |
Channels
Channel
channel: Channels and direct-message groups. Timestamps are in nanoseconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique identifier (UUID) |
user_id | Text | — | Owner/creator of channel |
type | Text | — | Channel type |
name | Text | — | Channel name |
description | Text | — | Channel description |
is_private | Boolean | — | Private group channel |
data | JSON | — | Flexible data storage |
meta | JSON | — | Channel metadata |
created_at | BigInteger | — | Creation timestamp (nanoseconds) |
updated_at | BigInteger | — | Last update timestamp (nanoseconds) |
updated_by | Text | — | User who last changed the channel |
archived_at | BigInteger | — | When the channel was archived |
archived_by | Text | — | User who archived it |
deleted_at | BigInteger | — | When the channel was deleted (soft delete) |
deleted_by | Text | — | User who deleted it |
- Channel names are stored in lowercase. Deleting a channel is a soft delete (
deleted_at).
Channel Member
channel_member: Channel membership and read state. Timestamps are in nanoseconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique identifier for the channel membership |
channel_id | Text | NOT NULL | Reference to the channel |
user_id | Text | NOT NULL | Reference to the user |
role | Text | — | Member role, e.g. manager |
status | Text | — | Membership status, e.g. joined or left |
is_active | Boolean | NOT NULL, default True | Whether the membership is active |
is_channel_muted | Boolean | NOT NULL, default False | Member muted the channel |
is_channel_pinned | Boolean | NOT NULL, default False | Member pinned the channel |
data | JSON | — | Additional data |
meta | JSON | — | Metadata |
invited_at | BigInteger | — | When the member was invited |
invited_by | Text | — | User who invited them |
joined_at | BigInteger | — | When the member joined |
left_at | BigInteger | — | When the member left |
last_read_at | BigInteger | — | Last read position, for unread counts |
created_at | BigInteger | — | Timestamp when membership was created |
updated_at | BigInteger | — | Last update timestamp |
- Unique on (
channel_id,user_id).
Channel File
channel_file: Files posted in channels. Timestamps are in nanoseconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique identifier (UUID) |
user_id | Text | NOT NULL | Owner of the relationship |
channel_id | Text | FK → channel.id (cascade), NOT NULL | Reference to the channel |
message_id | Text | FK → message.id (cascade) | Reference to associated message |
file_id | Text | FK → file.id (cascade), NOT NULL | Reference to the file |
created_at | BigInteger | NOT NULL | Creation timestamp |
updated_at | BigInteger | NOT NULL | Last update timestamp |
- Unique on (
channel_id,file_id). Deleting the channel, file or message deletes the link.
Channel Webhook
channel_webhook: Incoming webhooks that post to channels. Timestamps are in nanoseconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique identifier |
channel_id | Text | NOT NULL | Channel the webhook posts to |
user_id | Text | NOT NULL | User who created it |
name | Text | NOT NULL | Name shown as the message author |
profile_image_url | Text | — | Avatar shown on its messages |
token | Text | NOT NULL | Secret token in the webhook URL |
last_used_at | BigInteger | — | Last time it posted |
created_at | BigInteger | NOT NULL | Creation timestamp |
updated_at | BigInteger | NOT NULL | Last update timestamp |
Message
message: Channel messages and threads. Timestamps are in nanoseconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique identifier (UUID) |
user_id | Text | — | Message author |
channel_id | Text | — | Associated channel |
reply_to_id | Text | — | Message this one quotes in a reply |
parent_id | Text | — | Parent message for threads |
is_pinned | Boolean | NOT NULL, default False | Pinned in the channel |
pinned_at | BigInteger | — | When it was pinned |
pinned_by | Text | — | User who pinned it |
content | Text | — | Message content |
data | JSON | — | Additional message data |
meta | JSON | — | Message metadata |
created_at | BigInteger | — | Creation timestamp (nanoseconds) |
updated_at | BigInteger | — | Last update timestamp (nanoseconds) |
- Indexed for the channel timeline, pinned messages and thread replies.
parent_idis the thread root;reply_to_ida quoted message.
Message Reaction
message_reaction: Reactions to channel messages. Timestamps are in nanoseconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique identifier (UUID) |
user_id | Text | — | User who reacted |
message_id | Text | — | Associated message |
name | Text | — | Reaction name/emoji |
created_at | BigInteger | — | Reaction timestamp |
Files & Knowledge
File
file: Uploaded files and their metadata. Timestamps are in seconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | String | PRIMARY KEY | Unique identifier |
user_id | String | — | Owner of the file |
hash | Text | — | File hash/checksum |
filename | Text | — | Name of the file |
path | Text | — | File system path |
data | JSON | — | File-related data |
meta | JSON | — | File metadata |
created_at | BigInteger | — | Creation timestamp |
updated_at | BigInteger | — | Last update timestamp |
deleted_at | BigInteger | — | When the file was deleted (soft delete) |
deleted_by | Text | — | User who deleted it |
metaholdsname,content_typeandsize(bytes), plus any extra keys.
Knowledge
knowledge: Knowledge bases. Timestamps are in seconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique identifier (UUID) |
user_id | Text | — | Knowledge base owner |
space_id | Text | FK → space.id (set null), indexed | Space it belongs to (null when personal) |
name | Text | — | Knowledge base name |
description | Text | — | Knowledge base description |
meta | JSON | — | Additional metadata |
chunk_strategy | String | — | Chunking override: character, token or markdown (null: global setting) |
chunk_size | Integer | — | Chunk size override (null: global setting) |
chunk_overlap | Integer | — | Chunk overlap override (null: global setting) |
created_at | BigInteger | — | Creation timestamp |
updated_at | BigInteger | — | Last update timestamp |
Knowledge File
knowledge_file: Files in each knowledge base. Timestamps are in seconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique identifier (UUID) |
knowledge_id | Text | FK → knowledge.id (cascade), NOT NULL | Reference to the knowledge base |
file_id | Text | FK → file.id (cascade), NOT NULL | Reference to the file |
user_id | Text | NOT NULL | Owner of the relationship |
created_at | BigInteger | NOT NULL | Creation timestamp |
updated_at | BigInteger | NOT NULL | Last update timestamp |
- Unique on (
knowledge_id,file_id). Deleting the knowledge base or the file deletes the link.
Models, Prompts, Tools & Skills
Model
model: Workspace models (presets on top of base models). Timestamps are in seconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Model identifier |
user_id | Text | — | Model owner |
base_model_id | Text | — | Parent model reference |
name | Text | — | Display name |
params | JSON | — | Model parameters |
meta | JSON | — | Model metadata |
is_active | Boolean | default True | Active status |
updated_at | BigInteger | — | Last update timestamp |
created_at | BigInteger | — | Creation timestamp |
Model Pricing
model_pricing: Token prices per model, for cost reports. Timestamps are in seconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique identifier |
model_id | Text | NOT NULL, UNIQUE, indexed | Model the price applies to |
provider | Text | — | Provider name |
input_cost_per_million | Numeric(18, 8) | NOT NULL, default 0 | Price per 1,000,000 input tokens |
output_cost_per_million | Numeric(18, 8) | NOT NULL, default 0 | Price per 1,000,000 output tokens |
currency | Text | NOT NULL, default USD | Currency code |
is_active | Boolean | NOT NULL, default True | Whether the price is used |
created_at | BigInteger | NOT NULL | Creation timestamp |
updated_at | BigInteger | NOT NULL | Last update timestamp |
Prompt
prompt: Prompt templates (/ commands). Timestamps are in seconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique identifier (UUID) |
command | String | UNIQUE, indexed | Unique command identifier |
user_id | String | — | Owner of the prompt |
space_id | Text | FK → space.id (set null), indexed | Space it belongs to (null when personal) |
name | Text | — | Display name of the prompt |
content | Text | — | Prompt content/template |
data | JSON | — | Additional prompt data |
meta | JSON | — | Prompt metadata |
tags | JSON | — | Associated tags |
is_active | Boolean | default True | Active status |
version_id | Text | — | Active entry in prompt_history |
created_at | BigInteger | — | Creation timestamp |
updated_at | BigInteger | — | Last update timestamp |
Prompt History
prompt_history: Prompt versions. Timestamps are in seconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique identifier (UUID) |
prompt_id | Text | NOT NULL, indexed | Reference to the prompt |
parent_id | Text | — | Reference to the parent version |
snapshot | JSON | NOT NULL | Snapshot of the prompt at version |
user_id | Text | NOT NULL | User who created the version |
commit_message | Text | — | Version commit message |
created_at | BigInteger | NOT NULL | Creation timestamp |
Tool
tool: Tools (Python toolkits). Timestamps are in seconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | String | PRIMARY KEY | Unique identifier |
user_id | String | — | Tool owner |
space_id | String | FK → space.id (set null), indexed | Space it belongs to (null when personal) |
name | Text | — | Tool name |
content | Text | — | Tool content/code |
specs | JSON | — | Tool specifications |
meta | JSON | — | Tool metadata |
valves | JSON | — | Tool control settings |
updated_at | BigInteger | — | Last update timestamp |
created_at | BigInteger | — | Creation timestamp |
Function
function: Functions: filters, actions and pipes. Timestamps are in seconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | String | PRIMARY KEY | Unique identifier |
user_id | String | — | Owner of the function |
name | Text | — | Function name |
type | Text | — | filter, action or pipe |
content | Text | — | Function content/code |
meta | JSON | — | Function metadata |
valves | JSON | — | Function control settings |
is_active | Boolean | — | Function active status |
is_global | Boolean | — | Global availability flag |
updated_at | BigInteger | — | Last update timestamp |
created_at | BigInteger | — | Creation timestamp |
- Global functions (
is_global) apply to every model; others only where they are enabled on a model.
Skill
skill: Skills (Markdown instructions). Timestamps are in seconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | String | PRIMARY KEY | Unique identifier (UUID) |
user_id | String | — | Owner/creator of the skill |
space_id | String | FK → space.id (set null), indexed | Space it belongs to (null when personal) |
name | Text | UNIQUE | Display name of the skill |
description | Text | — | Short description (used in manifest) |
content | Text | — | Full skill instructions (Markdown) |
meta | JSON | — | Skill metadata |
is_active | Boolean | default True | Active status |
version_id | Text | — | Active entry in skill_history |
updated_at | BigInteger | — | Last update timestamp |
created_at | BigInteger | — | Creation timestamp |
descriptiongoes into the system prompt as part of the skills list;contentis loaded when the model callsview_skill.
Skill History
skill_history: Skill versions. Timestamps are in seconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique identifier (UUID) |
skill_id | Text | NOT NULL, indexed | The skill |
parent_id | Text | — | Previous version |
snapshot | JSON | NOT NULL | The skill as it was at this version |
user_id | Text | NOT NULL | User who saved the version |
commit_message | Text | — | Version note |
created_at | BigInteger | NOT NULL | Creation timestamp |
Notes, Calendar & Automations
Note
note: Notes. Timestamps are in nanoseconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique identifier |
user_id | Text | — | Owner of the note |
title | Text | — | Note title |
data | JSON | — | Note content and data |
meta | JSON | — | Note metadata |
created_at | BigInteger | — | Creation timestamp |
updated_at | BigInteger | — | Last update timestamp |
- Pins are per user, in
pinned_note; pinning doesn't changenote.updated_at.
Pinned Note
pinned_note: Notes each user pinned. Timestamps are in nanoseconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique identifier (UUID) |
user_id | Text | NOT NULL | The user who pinned the note |
note_id | Text | FK → note.id (cascade), NOT NULL | The pinned note |
created_at | BigInteger | NOT NULL | Pin creation timestamp (used for ordering) |
- Unique on (
user_id,note_id); listed newest pin first. Deleting the note deletes its pins.
Calendar
calendar: Calendars. Timestamps are in nanoseconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique identifier (UUID) |
user_id | Text | NOT NULL | Owner of the calendar |
name | Text | NOT NULL | Calendar display name |
color | Text | — | Display color (hex, e.g. #3b82f6) |
is_default | Boolean | NOT NULL, default False | Whether this is the user's default calendar |
data | JSON | — | Extensible data payload |
meta | JSON | — | Optional metadata |
created_at | BigInteger | NOT NULL | Creation timestamp |
updated_at | BigInteger | NOT NULL | Last update timestamp |
- A default Personal calendar is created on first use. Only non-default calendars can be deleted, and deleting one deletes its events, attendees and grants.
- The Scheduled Tasks calendar is not stored: the API builds it from automations at request time (ID
__scheduled_tasks__).
Calendar Event
calendar_event: Calendar events. Timestamps are in nanoseconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique identifier (UUID) |
calendar_id | Text | NOT NULL | Reference to parent calendar |
user_id | Text | NOT NULL | User who created the event |
title | Text | NOT NULL | Event title |
description | Text | — | Event description |
start_at | BigInteger | NOT NULL | Start time (epoch nanoseconds) |
end_at | BigInteger | — | End time (epoch nanoseconds) |
all_day | Boolean | NOT NULL, default False | Whether this is an all-day event |
rrule | Text | — | ICalendar RRULE for recurrence |
color | Text | — | Per-event color override |
location | Text | — | Event location |
data | JSON | — | Extensible data payload |
meta | JSON | — | Optional metadata (e.g. automation_id) |
is_cancelled | Boolean | NOT NULL, default False | Soft-cancel flag |
created_at | BigInteger | NOT NULL | Creation timestamp |
updated_at | BigInteger | NOT NULL | Last update timestamp |
- Recurring events store an
rruleand are expanded into instances when queried. Cancelled events stay in the table but are left out of queries.
Calendar Event Attendee
calendar_event_attendee: Event invitations and RSVPs. Timestamps are in nanoseconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique identifier (UUID) |
event_id | Text | NOT NULL | Reference to the calendar event |
user_id | Text | NOT NULL | User invited to the event |
status | Text | NOT NULL, default pending | RSVP status: pending, accepted, declined, tentative |
meta | JSON | — | Optional metadata |
created_at | BigInteger | NOT NULL | Creation timestamp |
updated_at | BigInteger | NOT NULL | Last update timestamp |
- Unique on (
event_id,user_id).statusispending,accepted,declinedortentative.
Automation
automation: Scheduled automations. Timestamps are in nanoseconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique identifier (UUID) |
user_id | Text | NOT NULL | Owner of the automation |
space_id | Text | FK → space.id (set null), indexed | Space it belongs to (null when personal) |
name | Text | NOT NULL | Automation display name |
data | JSON | NOT NULL | Automation payload (prompt, model_id, rrule, optional terminal config) |
meta | JSON | — | Optional metadata |
is_active | Boolean | NOT NULL, default True | Active/paused state |
last_run_at | BigInteger | — | Last run time |
next_run_at | BigInteger | — | Next scheduled run time |
created_at | BigInteger | NOT NULL | Creation timestamp |
updated_at | BigInteger | NOT NULL | Last update timestamp |
dataholds the prompt, model,rruleand optional terminal settings.next_run_atis indexed for the scheduler.
Automation Run
automation_run: Automation run history. Timestamps are in nanoseconds.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Text | PRIMARY KEY | Unique identifier (UUID) |
automation_id | Text | NOT NULL | Reference to automation |
chat_id | Text | — | Chat created by this run (if available) |
status | Text | NOT NULL | success, error or skipped |
error | Text | — | Error details when status is error |
delivery | JSON | — | How the report was delivered, e.g. by email (null: none requested) |
artifacts | JSON | — | Report files the run wrote, copied into Studio files |
created_at | BigInteger | NOT NULL | Run record timestamp |
- Deleting an automation deletes its runs.
System
Config
config: Persistent admin settings.
| Column | Type | Constraints | Description |
|---|---|---|---|
id | Integer | PRIMARY KEY | Primary key identifier |
data | JSON | NOT NULL | Configuration data |
version | Integer | NOT NULL, default 0 | Config version number |
created_at | DateTime | NOT NULL, default now | Creation timestamp |
updated_at | DateTime | — | Last update timestamp |
- A single row holds the persistent admin settings as JSON. Values saved here take precedence over environment variables, unless
ENABLE_PERSISTENT_CONFIG=False.
Entity Relationships
How the core tables relate. Most tables also have a user_id owner, left out here for readability.
access_grant links any resource (model, knowledge base, tool, prompt, note, channel, file, skill, calendar, shared chat) to a user or group, through resource_type + resource_id and principal_type + principal_id.
Encrypting SQLite with SQLCipher
Hrida.ai can encrypt the SQLite database at rest with SQLCipher, for deployments with sensitive data that don't need PostgreSQL.
Prerequisites
SQLCipher needs dependencies that are not in the default image:
- the SQLCipher system library (
libsqlcipher-devon Debian/Ubuntu,sqlcipheron macOS with Homebrew); - the
sqlcipher3-wheelsPython package (pip install sqlcipher3-wheels).
For Docker, build a custom image that adds them.
Configuration
# Use SQLCipher for the database
DATABASE_TYPE=sqlite+sqlcipher
# The encryption password
DATABASE_PASSWORD=your-secure-passwordWhen these are set and DATABASE_URL is not, Hrida.ai creates and uses an encrypted database at ./data/hridaai.db.
DATABASE_PASSWORDis required withsqlite+sqlcipher.- Anyone with the password can read all application data, so store it in a secrets manager.
- Losing the password means losing all data in the encrypted database.
Hrida.ai can't convert an existing unencrypted database to SQLCipher. If you turn SQLCipher on for an existing installation, it can't read the old data. Instead, either:
- Start fresh on a new installation, and have users export and re-import their chats;
- Migrate by hand with SQLite/SQLCipher tools, exporting from the old database into a new encrypted one (advanced);
- Encrypt the disk instead, with LUKS (Linux) or BitLocker (Windows), with no database change;
- Switch to PostgreSQL with TLS and encrypted storage, which also suits multi-user deployments.
Database Settings
| Variable | Default | Description |
|---|---|---|
DATABASE_URL | SQLite in DATA_DIR | Database connection URL, e.g. postgresql://user:pass@host:5432/hridaai |
DATABASE_TYPE | None | sqlite+sqlcipher for encrypted SQLite |
DATABASE_PASSWORD | — | Encryption password (required for SQLCipher) |
DATABASE_ENABLE_SQLITE_WAL | True | Write-ahead logging, for better concurrency |
DATABASE_SQLITE_PRAGMA_SYNCHRONOUS | NORMAL | SQLite sync mode (safe with WAL; avoids an fsync per transaction) |
DATABASE_SQLITE_PRAGMA_BUSY_TIMEOUT | 5000 | How long a write waits for a lock, in milliseconds |
DATABASE_SQLITE_PRAGMA_CACHE_SIZE | -65536 | Page cache size (negative = KiB; about 64 MB) |
DATABASE_SQLITE_PRAGMA_TEMP_STORE | MEMORY | Keep temporary tables in RAM |
DATABASE_SQLITE_PRAGMA_MMAP_SIZE | 268435456 | Memory-mapped I/O size in bytes (about 256 MB) |
DATABASE_SQLITE_PRAGMA_JOURNAL_SIZE_LIMIT | 67108864 | Largest WAL file kept after a checkpoint (about 64 MB) |
DATABASE_POOL_SIZE | None | Connection pool size |
DATABASE_POOL_TIMEOUT | 30 | Seconds to wait for a pooled connection |
DATABASE_POOL_RECYCLE | 3600 | Seconds before a pooled connection is replaced |
For every database variable, see Environment Variable Configuration.