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() β€” β€”