Skip to content

Schema: people

Part of the generated database reference.

advisor_recommendations

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.5.28-advisor-recommendations
  • Rust source: botschema/src/people/marketing_campaign_events_tables.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK โ€”
branch_id UUID no โ€” FK branches.id
campaign_id UUID yes โ€” โ€” โ€”
recommendation TEXT no โ€” โ€” โ€”
reason TEXT yes โ€” โ€” โ€”
check_name varchar no โ€” โ€” โ€”
severity VARCHAR(20) no โ€” โ€” โ€”
message TEXT no โ€” โ€” โ€”
details TEXT yes โ€” โ€” โ€”
dismissed BOOLEAN no FALSE โ€” โ€”
created_at TIMESTAMPTZ no NOW() โ€” โ€”

Indexes: idx_advisor_rec_branch(branch_id), idx_advisor_rec_severity(severity)

Drift: not found in migrations: check_name

attendance_sla_events

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.5.15.1-consolidated
  • Rust source: botschema/src/people/people_skills_tables.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK โ€”
session_id UUID no โ€” โ€” โ€”
sla_policy_id UUID no โ€” FK attendance_sla_policies.id
event_type VARCHAR(255) no โ€” โ€” โ€”
due_at TIMESTAMPTZ no โ€” โ€” โ€”
met_at TIMESTAMPTZ yes โ€” โ€” โ€”
breached_at TIMESTAMPTZ yes โ€” โ€” โ€”
status VARCHAR(255) yes 'pending' โ€” โ€”
created_at TIMESTAMPTZ no NOW() โ€” โ€”

attendance_sla_policies

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.5.23-branch-scope-cleanup
  • Rust source: botschema/src/people/people_skills_tables.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK โ€”
org_id UUID no โ€” FK organizations.org_id
bot_id uuid no โ€” โ€” โ€”
name VARCHAR(255) no โ€” โ€” โ€”
channel VARCHAR(255) yes โ€” โ€” โ€”
priority VARCHAR(255) yes โ€” โ€” โ€”
first_response_minutes INTEGER yes 15 โ€” โ€”
resolution_minutes INTEGER yes 240 โ€” โ€”
escalate_on_breach BOOLEAN yes TRUE โ€” โ€”
is_active BOOLEAN yes TRUE โ€” โ€”
created_at TIMESTAMPTZ no NOW() โ€” โ€”
branch_id UUID yes โ€” FK branches.id

attendance_webhooks

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.5.23-branch-scope-cleanup
  • Rust source: botschema/src/people/people_skills_tables.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK โ€”
org_id UUID no โ€” FK organizations.org_id
branch_id UUID yes โ€” FK branches.id
webhook_url VARCHAR(255) no โ€” โ€” โ€”
events TEXT[] yes โ€” โ€” โ€”
is_active BOOLEAN yes TRUE โ€” โ€”
secret_key TEXT yes โ€” โ€” โ€”
created_at TIMESTAMPTZ no NOW() โ€” โ€”
updated_at TIMESTAMPTZ yes NOW() โ€” โ€”

campaign_metrics

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.7.12-missing-feature-tables
  • Rust source: botschema/src/people/marketing_campaign_events_tables.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK โ€”
branch_id UUID no โ€” โ€” โ€”
campaign_id UUID yes โ€” โ€” โ€”
metric_type VARCHAR(50) no โ€” โ€” โ€”
metric_value NUMERIC no 0 โ€” โ€”
recorded_at TIMESTAMPTZ no NOW() โ€” โ€”
created_at TIMESTAMPTZ no NOW() โ€” โ€”

Indexes: idx_campaign_metrics_campaign(campaign_id, metric_type)

crm_accounts

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.7.5-crm-numeric-to-float8
  • Rust source: botschema/src/people.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK โ€”
org_id UUID no โ€” FK branches.id
bot_id UUID no โ€” FK bots.id
name VARCHAR(255) no โ€” โ€” โ€”
website VARCHAR(255) yes โ€” โ€” โ€”
industry VARCHAR(255) yes โ€” โ€” โ€”
employees_count INTEGER yes โ€” โ€” โ€”
annual_revenue DOUBLE PRECISION yes โ€” โ€” โ€”
phone VARCHAR(255) yes โ€” โ€” โ€”
email VARCHAR(255) yes โ€” โ€” โ€”
address_line1 VARCHAR(255) yes โ€” โ€” โ€”
address_line2 VARCHAR(255) yes โ€” โ€” โ€”
city VARCHAR(255) yes โ€” โ€” โ€”
state VARCHAR(255) yes โ€” โ€” โ€”
postal_code VARCHAR(255) yes โ€” โ€” โ€”
country VARCHAR(255) yes โ€” โ€” โ€”
description TEXT yes โ€” โ€” โ€”
tags TEXT[] no '{}' โ€” โ€”
custom_fields JSONB no '{}' โ€” โ€”
owner_id UUID yes โ€” FK users.id
created_at TIMESTAMPTZ no NOW() โ€” โ€”
updated_at TIMESTAMPTZ no NOW() โ€” โ€”
branch_id UUID yes โ€” FK branches.id

crm_activities

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.5.23-branch-scope-cleanup
  • Rust source: botschema/src/people.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK โ€”
org_id UUID no โ€” FK organizations.org_id
bot_id UUID no โ€” FK bots.id
contact_id UUID yes โ€” FK crm_contacts.id
lead_id UUID yes โ€” FK crm_leads.id
opportunity_id UUID yes โ€” FK crm_opportunities.id
account_id UUID yes โ€” FK crm_accounts.id
activity_type VARCHAR(255) no โ€” โ€” โ€”
subject VARCHAR(255) yes โ€” โ€” โ€”
description TEXT yes โ€” โ€” โ€”
due_date TIMESTAMPTZ yes โ€” โ€” โ€”
completed_at TIMESTAMPTZ yes โ€” โ€” โ€”
outcome VARCHAR(255) yes โ€” โ€” โ€”
owner_id UUID yes โ€” FK users.id
created_at TIMESTAMPTZ no NOW() โ€” โ€”
branch_id UUID yes โ€” FK branches.id

crm_audit_logs

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.7.3-crm-audit-trail
  • Rust source: botschema/src/people.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK โ€”
branch_id UUID no โ€” โ€” โ€”
entity VARCHAR(40) no โ€” โ€” โ€”
entity_id UUID yes โ€” โ€” โ€”
action VARCHAR(40) no โ€” โ€” โ€”
actor_email VARCHAR(255) yes โ€” โ€” โ€”
before JSONB yes โ€” โ€” โ€”
after JSONB yes โ€” โ€” โ€”
detail JSONB yes โ€” โ€” โ€”
created_at TIMESTAMPTZ no NOW() โ€” โ€”

Indexes: idx_crm_audit_logs_branch_created(branch_id, created_at DESC), idx_crm_audit_logs_entity(entity, entity_id)

crm_contacts

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.5.23-branch-scope-cleanup
  • Rust source: botschema/src/people.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK โ€”
org_id UUID no โ€” FK branches.id
bot_id UUID no โ€” FK bots.id
first_name VARCHAR(255) yes โ€” โ€” โ€”
last_name VARCHAR(255) yes โ€” โ€” โ€”
email VARCHAR(255) yes โ€” โ€” โ€”
phone VARCHAR(255) yes โ€” โ€” โ€”
mobile VARCHAR(255) yes โ€” โ€” โ€”
company VARCHAR(255) yes โ€” โ€” โ€”
job_title VARCHAR(255) yes โ€” โ€” โ€”
source VARCHAR(255) yes โ€” โ€” โ€”
status VARCHAR(255) no 'active' โ€” โ€”
tags TEXT[] no '{}' โ€” โ€”
custom_fields JSONB no '{}' โ€” โ€”
address_line1 VARCHAR(255) yes โ€” โ€” โ€”
address_line2 VARCHAR(255) yes โ€” โ€” โ€”
city VARCHAR(255) yes โ€” โ€” โ€”
state VARCHAR(255) yes โ€” โ€” โ€”
postal_code VARCHAR(255) yes โ€” โ€” โ€”
country VARCHAR(255) yes โ€” โ€” โ€”
notes TEXT yes โ€” โ€” โ€”
owner_id UUID yes โ€” FK users.id
created_at TIMESTAMPTZ no NOW() โ€” โ€”
updated_at TIMESTAMPTZ no NOW() โ€” โ€”
branch_id UUID yes โ€” FK branches.id
pass_hash VARCHAR(255) yes โ€” โ€” โ€”

Indexes: idx_unified_search_crm_contacts(to_tsvector('english', COALESCE(first_name::text, '')

crm_deal_segments

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.5.23-branch-scope-cleanup
  • Rust source: botschema/src/people/people_skills_tables.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK โ€”
org_id UUID no โ€” FK organizations.org_id
bot_id uuid no โ€” โ€” โ€”
name VARCHAR(255) no โ€” โ€” โ€”
description VARCHAR(255) yes โ€” โ€” โ€”
created_at TIMESTAMPTZ no NOW() โ€” โ€”
branch_id UUID yes โ€” FK branches.id

crm_deals

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.7.4-crm-deal-lead-fk
  • Rust source: botschema/src/people/people_skills_tables.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK โ€”
org_id UUID no โ€” FK branches.id
bot_id uuid no โ€” โ€” โ€”
contact_id UUID yes โ€” FK crm_contacts.id
account_id UUID yes โ€” FK crm_accounts.id
am_id UUID yes โ€” FK users.id
owner_id UUID yes โ€” FK users.id
lead_id UUID yes โ€” FK crm_deals.id
title VARCHAR(255) yes โ€” โ€” โ€”
name VARCHAR(255) yes โ€” โ€” โ€”
description TEXT yes โ€” โ€” โ€”
value DOUBLE PRECISION yes โ€” โ€” โ€”
currency VARCHAR(255) yes โ€” โ€” โ€”
stage_id UUID yes โ€” FK crm_pipeline_stages.id
stage VARCHAR(255) yes โ€” โ€” โ€”
probability INTEGER no 0 โ€” โ€”
won BOOLEAN yes โ€” โ€” โ€”
source VARCHAR(255) yes โ€” โ€” โ€”
segment_id UUID yes โ€” FK crm_deal_segments.id
expected_close_date VARCHAR(255) yes โ€” โ€” โ€”
actual_close_date VARCHAR(255) yes โ€” โ€” โ€”
period INTEGER yes โ€” โ€” โ€”
deal_date VARCHAR(255) yes โ€” โ€” โ€”
closed_at TIMESTAMPTZ yes โ€” โ€” โ€”
created_at TIMESTAMPTZ no NOW() โ€” โ€”
updated_at TIMESTAMPTZ yes NOW() โ€” โ€”
notes TEXT yes โ€” โ€” โ€”
tags TEXT[] no โ€” โ€” โ€”
custom_fields JSONB no '{}' โ€” โ€”
department_id UUID yes โ€” FK people_departments.id
lost_reason VARCHAR(255) yes โ€” โ€” โ€”
branch_id UUID yes โ€” FK branches.id

crm_leads

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.5.23-branch-scope-cleanup
  • Rust source: botschema/src/people.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK โ€”
org_id UUID no โ€” FK organizations.org_id
bot_id UUID no โ€” FK bots.id
contact_id UUID yes โ€” FK crm_contacts.id
account_id UUID yes โ€” FK crm_accounts.id
title VARCHAR(255) no โ€” โ€” โ€”
description TEXT yes โ€” โ€” โ€”
value DOUBLE PRECISION yes โ€” โ€” โ€”
currency VARCHAR(255) yes 'USD' โ€” โ€”
stage_id UUID yes โ€” FK crm_pipeline_stages.id
stage VARCHAR(255) no 'new' โ€” โ€”
probability INTEGER no 0 โ€” โ€”
source VARCHAR(255) yes โ€” โ€” โ€”
expected_close_date VARCHAR(255) yes โ€” โ€” โ€”
owner_id UUID yes โ€” FK users.id
lost_reason VARCHAR(255) yes โ€” โ€” โ€”
tags TEXT[] no '{}' โ€” โ€”
custom_fields JSONB no '{}' โ€” โ€”
created_at TIMESTAMPTZ no NOW() โ€” โ€”
updated_at TIMESTAMPTZ no NOW() โ€” โ€”
closed_at TIMESTAMPTZ yes โ€” โ€” โ€”
branch_id UUID yes โ€” FK branches.id

crm_notes

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.5.15.1-consolidated
  • Rust source: botschema/src/people.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK โ€”
org_id UUID no โ€” FK organizations.org_id
contact_id UUID yes โ€” FK crm_contacts.id
lead_id UUID yes โ€” FK crm_leads.id
opportunity_id UUID yes โ€” FK crm_opportunities.id
account_id UUID yes โ€” FK crm_accounts.id
content TEXT no โ€” โ€” โ€”
author_id UUID yes โ€” FK users.id
created_at TIMESTAMPTZ no NOW() โ€” โ€”
updated_at TIMESTAMPTZ no NOW() โ€” โ€”
branch_id UUID yes โ€” FK branches.id

crm_opportunities

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.5.23-branch-scope-cleanup
  • Rust source: botschema/src/people.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK โ€”
org_id UUID no โ€” FK organizations.org_id
bot_id UUID no โ€” FK bots.id
lead_id UUID yes โ€” FK crm_leads.id
account_id UUID yes โ€” FK crm_accounts.id
contact_id UUID yes โ€” FK crm_contacts.id
name VARCHAR(255) no โ€” โ€” โ€”
description TEXT yes โ€” โ€” โ€”
value DOUBLE PRECISION yes โ€” โ€” โ€”
currency VARCHAR(255) yes 'USD' โ€” โ€”
stage_id UUID yes โ€” FK crm_pipeline_stages.id
stage VARCHAR(255) no 'qualification' โ€” โ€”
probability INTEGER no 0 โ€” โ€”
source VARCHAR(255) yes โ€” โ€” โ€”
expected_close_date VARCHAR(255) yes โ€” โ€” โ€”
actual_close_date VARCHAR(255) yes โ€” โ€” โ€”
won BOOLEAN yes โ€” โ€” โ€”
owner_id UUID yes โ€” FK users.id
tags TEXT[] no '{}' โ€” โ€”
custom_fields JSONB no '{}' โ€” โ€”
created_at TIMESTAMPTZ no NOW() โ€” โ€”
updated_at TIMESTAMPTZ no NOW() โ€” โ€”
branch_id UUID yes โ€” FK branches.id

crm_pipeline_stages

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.5.23-branch-scope-cleanup
  • Rust source: botschema/src/people.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK โ€”
org_id UUID no โ€” FK organizations.org_id
bot_id UUID no โ€” FK bots.id
name VARCHAR(255) no โ€” โ€” โ€”
stage_order INTEGER no โ€” โ€” โ€”
probability INTEGER no 0 โ€” โ€”
is_won BOOLEAN no FALSE โ€” โ€”
is_lost BOOLEAN no FALSE โ€” โ€”
color VARCHAR(255) yes '#3b82f6' โ€” โ€”
created_at TIMESTAMPTZ no NOW() โ€” โ€”
branch_id UUID yes โ€” FK branches.id

email_tracking

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.5.15.1-consolidated
  • Rust source: botschema/src/people/people_skills_tables.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK โ€”
recipient_id UUID yes โ€” FK marketing_recipients.id
campaign_id UUID yes โ€” FK marketing_campaigns.id
message_id VARCHAR(255) yes โ€” โ€” โ€”
open_token UUID yes โ€” UQ โ€”
open_tracking_enabled BOOLEAN yes true โ€” โ€”
opened BOOLEAN yes false โ€” โ€”
opened_at TIMESTAMPTZ yes โ€” โ€” โ€”
clicked BOOLEAN yes false โ€” โ€”
clicked_at TIMESTAMPTZ yes โ€” โ€” โ€”
ip_address VARCHAR(255) yes โ€” โ€” โ€”
user_agent TEXT yes โ€” โ€” โ€”
created_at TIMESTAMPTZ no NOW() โ€” โ€”