Skip to content

Schema: mail

Part of the generated database reference.

distribution_lists

  • Domain: mail Β· Feature gate: #[cfg(feature = "mail")] Β· Migration: 6.5.23-branch-scope-cleanup
  • Rust source: botschema/src/mail.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK β€”
bot_id UUID no β€” FK bots.id
owner_id UUID no β€” FK users.id
name VARCHAR(255) no β€” β€” β€”
email_alias VARCHAR(255) yes β€” β€” β€”
description TEXT yes β€” β€” β€”
members_json TEXT no '[]' β€” β€”
is_public BOOLEAN no FALSE β€” β€”
created_at TIMESTAMPTZ no NOW() β€” β€”
updated_at TIMESTAMPTZ no NOW() β€” β€”
branch_id UUID yes β€” FK branches.id

Drift: in migrations only: stalwart_principal_id

email_auto_responders

  • Domain: mail Β· Feature gate: #[cfg(feature = "mail")] Β· Migration: 6.5.23-branch-scope-cleanup
  • Rust source: botschema/src/mail.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK β€”
user_id UUID no β€” FK users.id
bot_id UUID no β€” FK bots.id
responder_type VARCHAR(255) no 'out_of_office' β€” β€”
subject TEXT no β€” β€” β€”
body_html TEXT no β€” β€” β€”
body_plain TEXT yes β€” β€” β€”
start_date TIMESTAMPTZ yes β€” β€” β€”
end_date TIMESTAMPTZ yes β€” β€” β€”
send_to_internal_only BOOLEAN no false β€” β€”
exclude_addresses TEXT yes β€” β€” β€”
is_active BOOLEAN no TRUE β€” β€”
stalwart_sieve_id VARCHAR(255) yes β€” β€” β€”
created_at TIMESTAMPTZ no NOW() β€” β€”
updated_at TIMESTAMPTZ no NOW() β€” β€”
branch_id UUID yes β€” FK branches.id

email_drafts

  • Domain: mail Β· Feature gate: #[cfg(feature = "mail")] Β· Migration: 6.5.23-branch-scope-cleanup
  • Rust source: botschema/src/mail.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK β€”
user_id UUID no β€” FK users.id
account_id UUID no β€” FK user_email_accounts.id
to_address TEXT no β€” β€” β€”
cc_address TEXT yes β€” β€” β€”
bcc_address TEXT yes β€” β€” β€”
subject VARCHAR(255) yes β€” β€” β€”
body TEXT yes β€” β€” β€”
attachments JSONB no '[]'::jsonb β€” β€”
created_at TIMESTAMPTZ no NOW() β€” β€”
updated_at TIMESTAMPTZ no NOW() β€” β€”
branch_id UUID yes β€” FK branches.id

Indexes: idx_email_drafts_account_id(account_id), idx_email_drafts_user_id(user_id)

email_folders

  • Domain: mail Β· Feature gate: #[cfg(feature = "mail")] Β· Migration: 6.5.15.1-consolidated
  • Rust source: botschema/src/mail.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK β€”
account_id UUID no β€” FK user_email_accounts.id
folder_name VARCHAR(255) no β€” β€” β€”
folder_path VARCHAR(255) no β€” β€” β€”
unread_count INTEGER no 0 β€” β€”
total_count INTEGER no 0 β€” β€”
last_synced TIMESTAMPTZ yes β€” β€” β€”
created_at TIMESTAMPTZ no NOW() β€” β€”
updated_at TIMESTAMPTZ no NOW() β€” β€”

Indexes: idx_email_folders_account_id(account_id)

email_label_assignments

  • Domain: mail Β· Feature gate: #[cfg(feature = "mail")] Β· Migration: 6.5.15.1-consolidated
  • Rust source: botschema/src/mail.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK β€”
email_message_id VARCHAR(255) no β€” β€” β€”
label_id UUID no β€” FK email_labels.id
assigned_at TIMESTAMPTZ no NOW() β€” β€”

email_labels

  • Domain: mail Β· Feature gate: #[cfg(feature = "mail")] Β· Migration: 6.5.23-branch-scope-cleanup
  • Rust source: botschema/src/mail.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK β€”
user_id UUID no β€” FK users.id
bot_id UUID no β€” FK bots.id
name VARCHAR(255) no β€” β€” β€”
color VARCHAR(255) no '#3b82f6' β€” β€”
parent_id UUID yes β€” FK email_labels.id
is_system BOOLEAN no false β€” β€”
created_at TIMESTAMPTZ no NOW() β€” β€”
branch_id UUID yes β€” FK branches.id

email_messages

  • Domain: mail Β· Feature gate: #[cfg(feature = "mail")] Β· Migration: 6.4.0-01-email-v1-inbox
  • Rust source: botschema/src/mail.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK β€”
account_id UUID no β€” FK user_email_accounts.id
message_id_header VARCHAR(512) yes β€” β€” β€”
in_reply_to VARCHAR(512) yes β€” β€” β€”
subject TEXT no '' β€” β€”
normalized_subject TEXT no '' β€” β€”
from_address VARCHAR(512) no β€” β€” β€”
to_addresses TEXT yes β€” β€” β€”
body_text TEXT yes β€” β€” β€”
body_html TEXT yes β€” β€” β€”
has_attachments BOOLEAN yes false β€” β€”
folder VARCHAR(255) no 'INBOX' β€” β€”
uid BIGINT no β€” β€” β€”
flags JSONB yes '[]'::jsonb β€” β€”
is_read BOOLEAN yes false β€” β€”
is_flagged BOOLEAN yes false β€” β€”
received_at TIMESTAMPTZ no β€” β€” β€”
synced_at TIMESTAMPTZ no NOW() β€” β€”

email_rules

  • Domain: mail Β· Feature gate: #[cfg(feature = "mail")] Β· Migration: 6.5.23-branch-scope-cleanup
  • Rust source: botschema/src/mail.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK β€”
user_id UUID no β€” FK users.id
bot_id UUID no β€” FK bots.id
name VARCHAR(255) no β€” β€” β€”
priority INTEGER no 0 β€” β€”
conditions_json TEXT no β€” β€” β€”
actions_json TEXT no β€” β€” β€”
stop_processing BOOLEAN no false β€” β€”
is_active BOOLEAN no TRUE β€” β€”
stalwart_sieve_id VARCHAR(255) yes β€” β€” β€”
created_at TIMESTAMPTZ no NOW() β€” β€”
updated_at TIMESTAMPTZ no NOW() β€” β€”
branch_id UUID yes β€” FK branches.id

email_signatures

  • Domain: mail Β· Feature gate: #[cfg(feature = "mail")] Β· Migration: 6.5.23-branch-scope-cleanup
  • Rust source: botschema/src/mail.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK β€”
user_id UUID no β€” FK users.id
bot_id UUID yes β€” FK bots.id
name VARCHAR(255) no 'Default' β€” β€”
content_html TEXT no β€” β€” β€”
content_plain TEXT no β€” β€” β€”
is_default BOOLEAN no false β€” β€”
is_active BOOLEAN no TRUE β€” β€”
created_at TIMESTAMPTZ no NOW() β€” β€”
updated_at TIMESTAMPTZ no NOW() β€” β€”
branch_id UUID yes β€” FK branches.id

email_templates

  • Domain: mail Β· Feature gate: #[cfg(feature = "mail")] Β· Migration: 6.5.23-branch-scope-cleanup
  • Rust source: botschema/src/mail.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK β€”
bot_id UUID no β€” FK bots.id
user_id UUID yes β€” FK users.id
name VARCHAR(255) no β€” β€” β€”
description TEXT yes β€” β€” β€”
subject_template TEXT no β€” β€” β€”
body_html_template TEXT no β€” β€” β€”
body_plain_template TEXT yes β€” β€” β€”
variables_json TEXT no '[]' β€” β€”
category VARCHAR(255) yes β€” β€” β€”
is_shared BOOLEAN no false β€” β€”
usage_count INTEGER no 0 β€” β€”
created_at TIMESTAMPTZ no NOW() β€” β€”
updated_at TIMESTAMPTZ no NOW() β€” β€”
branch_id UUID yes β€” FK branches.id

global_email_signatures

  • Domain: mail Β· Feature gate: #[cfg(feature = "mail")] Β· Migration: 6.5.23-branch-scope-cleanup
  • Rust source: botschema/src/mail.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK β€”
bot_id UUID no β€” FK bots.id
name VARCHAR(255) no 'Default' β€” β€”
content_html TEXT no β€” β€” β€”
content_plain TEXT no β€” β€” β€”
position VARCHAR(255) no 'bottom' β€” β€”
is_active BOOLEAN no TRUE β€” β€”
created_at TIMESTAMPTZ no NOW() β€” β€”
updated_at TIMESTAMPTZ no NOW() β€” β€”
branch_id UUID yes β€” FK branches.id

scheduled_emails

  • Domain: mail Β· Feature gate: #[cfg(feature = "mail")] Β· Migration: 6.5.23-branch-scope-cleanup
  • Rust source: botschema/src/mail.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK β€”
user_id UUID no β€” FK users.id
bot_id UUID no β€” FK bots.id
to_addresses TEXT no β€” β€” β€”
cc_addresses TEXT yes β€” β€” β€”
bcc_addresses TEXT yes β€” β€” β€”
subject TEXT no β€” β€” β€”
body_html TEXT no β€” β€” β€”
body_plain TEXT yes β€” β€” β€”
attachments_json TEXT no '[]' β€” β€”
scheduled_at TIMESTAMPTZ no β€” β€” β€”
sent_at TIMESTAMPTZ yes β€” β€” β€”
status VARCHAR(255) no 'pending' β€” β€”
retry_count INTEGER no 0 β€” β€”
error_message TEXT yes β€” β€” β€”
created_at TIMESTAMPTZ no NOW() β€” β€”
branch_id UUID yes β€” FK branches.id

shared_mailbox_members

  • Domain: mail Β· Feature gate: #[cfg(feature = "mail")] Β· Migration: 6.5.15.1-consolidated
  • Rust source: botschema/src/mail.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK β€”
mailbox_id UUID no β€” FK shared_mailboxes.id
user_id UUID no β€” FK users.id
permission_level VARCHAR(255) no 'read' β€” β€”
added_at TIMESTAMPTZ no NOW() β€” β€”

shared_mailboxes

  • Domain: mail Β· Feature gate: #[cfg(feature = "mail")] Β· Migration: 6.5.23-branch-scope-cleanup
  • Rust source: botschema/src/mail.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK β€”
bot_id UUID no β€” FK bots.id
email_address VARCHAR(255) no β€” β€” β€”
display_name VARCHAR(255) no β€” β€” β€”
description TEXT yes β€” β€” β€”
settings_json TEXT no '{}' β€” β€”
stalwart_account_id VARCHAR(255) yes β€” β€” β€”
is_active BOOLEAN no TRUE β€” β€”
created_at TIMESTAMPTZ no NOW() β€” β€”
branch_id UUID yes β€” FK branches.id

user_email_accounts

  • Domain: mail Β· Feature gate: #[cfg(feature = "mail")] Β· Migration: 6.7.2-mail-account-oauth2
  • Rust source: botschema/src/mail.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK β€”
user_id UUID no β€” FK users.id
email VARCHAR(255) no β€” β€” β€”
display_name VARCHAR(255) yes β€” β€” β€”
imap_server VARCHAR(255) no β€” β€” β€”
imap_port INTEGER no 993 β€” β€”
smtp_server VARCHAR(255) no β€” β€” β€”
smtp_port INTEGER no 587 β€” β€”
username VARCHAR(255) no β€” β€” β€”
password_encrypted TEXT no β€” β€” β€”
is_primary BOOLEAN no false β€” β€”
is_active BOOLEAN no TRUE β€” β€”
created_at TIMESTAMPTZ no NOW() β€” β€”
updated_at TIMESTAMPTZ no NOW() β€” β€”
auth_mode varchar no β€” β€” β€”
oauth_provider varchar yes β€” β€” β€”
refresh_token_encrypted text yes β€” β€” β€”
access_token_encrypted text yes β€” β€” β€”
token_expires_at timestamptz yes β€” β€” β€”
last_sync_at timestamptz yes β€” β€” β€”
last_error text yes β€” β€” β€”
last_error_at timestamptz yes β€” β€” β€”

Indexes: idx_user_email_accounts_active(is_active), idx_user_email_accounts_auth_mode(auth_mode), idx_user_email_accounts_sync_health(is_active, last_error_at DESC), idx_user_email_accounts_user_id(user_id)

Drift: not found in migrations: access_token_encrypted, auth_mode, last_error, last_error_at, last_sync_at, oauth_provider, refresh_token_encrypted, token_expires_at