Skip to content

Schema: people (part 2)

Part of the generated database reference.

hr_clock_entries

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.5.09-hr-timeclock
  • Rust source: botschema/src/people/people_skills_tables.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK โ€”
bot_id UUID no โ€” โ€” โ€”
person_id UUID no โ€” โ€” โ€”
entry_type VARCHAR(20) no โ€” โ€” โ€”
timestamp TIMESTAMPTZ no NOW() โ€” โ€”
latitude NUMERIC(10,7) yes โ€” โ€” โ€”
longitude NUMERIC(10,7) yes โ€” โ€” โ€”
geofence_id UUID yes โ€” โ€” โ€”
device_id VARCHAR(100) yes โ€” โ€” โ€”
ip_address VARCHAR(64) yes โ€” โ€” โ€”
notes TEXT yes โ€” โ€” โ€”
created_at TIMESTAMPTZ no NOW() โ€” โ€”

hr_holidays

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.5.09-hr-timeclock
  • Rust source: botschema/src/people/people_skills_tables.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK โ€”
bot_id UUID no โ€” โ€” โ€”
name VARCHAR(100) no โ€” โ€” โ€”
holiday_date DATE no โ€” โ€” โ€”
is_recurring BOOLEAN no false โ€” โ€”
region VARCHAR(50) yes โ€” โ€” โ€”
created_at TIMESTAMPTZ no NOW() โ€” โ€”

hr_overtime_rules

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.5.09-hr-timeclock
  • Rust source: botschema/src/people/people_skills_tables.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK โ€”
bot_id UUID no โ€” โ€” โ€”
name VARCHAR(100) no โ€” โ€” โ€”
weekly_threshold_hours NUMERIC(5,2) no 44.0 โ€” โ€”
daily_threshold_hours NUMERIC(5,2) yes โ€” โ€” โ€”
overtime_multiplier NUMERIC(4,2) no 1.5 โ€” โ€”
night_shift_multiplier NUMERIC(4,2) no 1.2 โ€” โ€”
holiday_multiplier NUMERIC(4,2) no 2.0 โ€” โ€”
is_active BOOLEAN no true โ€” โ€”
created_at TIMESTAMPTZ no NOW() โ€” โ€”

hr_schedules

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.5.09-hr-timeclock
  • Rust source: botschema/src/people/people_skills_tables.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK โ€”
bot_id UUID no โ€” โ€” โ€”
person_id UUID no โ€” โ€” โ€”
weekday INTEGER no โ€” โ€” โ€”
start_time TIME no โ€” โ€” โ€”
end_time TIME no โ€” โ€” โ€”
break_minutes INTEGER no 60 โ€” โ€”
effective_from DATE no โ€” โ€” โ€”
effective_until DATE yes โ€” โ€” โ€”
created_at TIMESTAMPTZ no NOW() โ€” โ€”

hr_work_periods

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.5.09-hr-timeclock
  • Rust source: botschema/src/people/people_skills_tables.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK โ€”
bot_id UUID no โ€” โ€” โ€”
person_id UUID no โ€” โ€” โ€”
period_start DATE no โ€” โ€” โ€”
period_end DATE no โ€” โ€” โ€”
hours_worked NUMERIC(8,2) no 0 โ€” โ€”
hours_overtime NUMERIC(8,2) no 0 โ€” โ€”
hours_night NUMERIC(8,2) no 0 โ€” โ€”
absences INTEGER no 0 โ€” โ€”
status VARCHAR(30) no 'open' โ€” โ€”
created_at TIMESTAMPTZ no NOW() โ€” โ€”

ip_reputation

  • 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 โ€”
org_id UUID no โ€” โ€” โ€”
ip VARCHAR(64) no โ€” โ€” โ€”
provider VARCHAR(100) no โ€” โ€” โ€”
delivered BIGINT no 0 โ€” โ€”
bounced BIGINT no 0 โ€” โ€”
complained BIGINT no 0 โ€” โ€”
window_start TIMESTAMPTZ no NOW() โ€” โ€”
updated_at TIMESTAMPTZ yes โ€” โ€” โ€”

ip_rotations

  • 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 โ€”
org_id UUID no โ€” โ€” โ€”
ip_address VARCHAR(64) no โ€” โ€” โ€”
strategy VARCHAR(50) yes โ€” โ€” โ€”
current_index INTEGER yes โ€” โ€” โ€”
last_used TIMESTAMPTZ yes โ€” โ€” โ€”
is_active BOOLEAN yes โ€” โ€” โ€”
created_at TIMESTAMPTZ no NOW() โ€” โ€”
updated_at TIMESTAMPTZ no NOW() โ€” โ€”

Indexes: idx_ip_rotations_org(org_id, is_active)

marketing_campaign_events

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.5.47-campaign-worker
  • 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 '00000000-0000-0000-0000-000000000000' โ€” โ€”
campaign_id uuid no โ€” FK marketing_campaigns.id
channel varchar(20) yes โ€” โ€” โ€”
event_type varchar(20) no โ€” โ€” โ€”
recipient_email varchar(255) yes โ€” โ€” โ€”
status varchar(20) yes โ€” โ€” โ€”
error_message text yes โ€” โ€” โ€”
created_at timestamptz no now() โ€” โ€”

marketing_campaigns

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.5.47-campaign-worker
  • 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 โ€” โ€” โ€”
status VARCHAR(255) no 'draft' โ€” โ€”
campaign_type varchar no โ€” โ€” โ€”
content_template JSONB no '{}' โ€” โ€”
starts_at timestamptz yes โ€” โ€” โ€”
sent_at TIMESTAMPTZ yes โ€” โ€” โ€”
ends_at timestamptz yes โ€” โ€” โ€”
metrics JSONB no '{}' โ€” โ€”
budget DOUBLE PRECISION yes โ€” โ€” โ€”
created_at TIMESTAMPTZ no NOW() โ€” โ€”
updated_at TIMESTAMPTZ yes NOW() โ€” โ€”
deal_id UUID yes โ€” FK crm_deals.id
branch_id uuid yes โ€” FK branches.id
run_offset INTEGER yes 0 โ€” โ€”
pause_requested BOOLEAN yes false โ€” โ€”
stop_requested BOOLEAN yes false โ€” โ€”
started_at timestamptz yes โ€” โ€” โ€”
completed_at timestamptz yes โ€” โ€” โ€”

Drift: not found in migrations: campaign_type, ends_at, starts_at; in migrations only: channel, scheduled_at

marketing_contacts

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.5.50-marketing-contacts
  • 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
list_id UUID yes โ€” FK marketing_lists.id
email VARCHAR no โ€” โ€” โ€”
name VARCHAR yes โ€” โ€” โ€”
phone VARCHAR yes โ€” โ€” โ€”
metadata JSONB yes โ€” โ€” โ€”
subscribed BOOLEAN yes true โ€” โ€”
created_at TIMESTAMPTZ no NOW() โ€” โ€”
updated_at TIMESTAMPTZ no NOW() โ€” โ€”

marketing_email_opens

  • 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 โ€” โ€” โ€”
email VARCHAR(255) no โ€” โ€” โ€”
opened_at TIMESTAMPTZ no NOW() โ€” โ€”
ip_address VARCHAR(64) yes โ€” โ€” โ€”
user_agent TEXT yes โ€” โ€” โ€”

Indexes: idx_marketing_email_opens_email(email, opened_at)

marketing_list_contacts

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.5.51-isolated-marketing-lists
  • Rust source: botschema/src/people/people_skills_tables.rs
Column SQL type Null Default Key References
list_id UUID no โ€” PK, FK marketing_lists.id
contact_id UUID no โ€” PK, FK crm_contacts.id
added_at TIMESTAMPTZ no now() โ€” โ€”

marketing_lists

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.5.36-schema-reconcile
  • 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 โ€” โ€” โ€”
list_type VARCHAR(255) no โ€” โ€” โ€”
query_text TEXT yes โ€” โ€” โ€”
contact_count INTEGER yes 0 โ€” โ€”
created_at TIMESTAMPTZ no NOW() โ€” โ€”
updated_at TIMESTAMPTZ yes NOW() โ€” โ€”
branch_id UUID yes โ€” FK branches.id
description TEXT yes โ€” โ€” โ€”
member_count INTEGER yes 0 โ€” โ€”
is_dynamic BOOLEAN yes FALSE โ€” โ€”
criteria JSONB yes '{}'::jsonb โ€” โ€”

marketing_recipients

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.5.48-marketing-recipients-reconcile
  • Rust source: botschema/src/people/people_skills_tables.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK โ€”
campaign_id UUID yes โ€” FK marketing_campaigns.id
contact_id UUID yes โ€” FK crm_contacts.id
deal_id UUID yes โ€” FK crm_deals.id
channel VARCHAR(255) no โ€” โ€” โ€”
status VARCHAR(255) no 'pending' โ€” โ€”
sent_at TIMESTAMPTZ yes โ€” โ€” โ€”
delivered_at TIMESTAMPTZ yes โ€” โ€” โ€”
failed_at TIMESTAMPTZ yes โ€” โ€” โ€”
error_message TEXT yes โ€” โ€” โ€”
response JSONB yes โ€” โ€” โ€”
created_at TIMESTAMPTZ no NOW() โ€” โ€”
branch_id uuid no '00000000-0000-0000-0000-000000000000' โ€” โ€”
list_id uuid yes โ€” โ€” โ€”
email varchar(255) yes โ€” โ€” โ€”
name varchar(255) yes โ€” โ€” โ€”
opened_at timestamptz yes โ€” โ€” โ€”
clicked_at timestamptz yes โ€” โ€” โ€”

marketing_suppressions

  • Domain: people ยท Feature gate: #[cfg(feature = "people")] ยท Migration: 6.9.2-marketing-suppressions
  • Rust source: botschema/src/people/people_skills_tables.rs
Column SQL type Null Default Key References
id UUID no gen_random_uuid() PK โ€”
branch_id UUID no โ€” โ€” โ€”
email TEXT no โ€” โ€” โ€”
channel TEXT no โ€” โ€” โ€”
reason TEXT no 'unsubscribed' โ€” โ€”
created_at TIMESTAMPTZ no NOW() โ€” โ€”

Indexes: marketing_suppressions_branch_channel_email_idx(branch_id, channel, email), marketing_suppressions_branch_email_idx(branch_id, email)

marketing_templates

  • 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) no โ€” โ€” โ€”
subject VARCHAR(255) yes โ€” โ€” โ€”
body TEXT yes โ€” โ€” โ€”
media_url VARCHAR(255) yes โ€” โ€” โ€”
ai_prompt TEXT yes โ€” โ€” โ€”
variables JSONB no '[]' โ€” โ€”
approved BOOLEAN yes false โ€” โ€”
meta_template_id VARCHAR(255) yes โ€” โ€” โ€”
created_at TIMESTAMPTZ no NOW() โ€” โ€”
updated_at TIMESTAMPTZ yes NOW() โ€” โ€”
branch_id UUID yes โ€” FK branches.id

org_ips

  • 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 โ€”
org_id UUID no โ€” โ€” โ€”
ip_address VARCHAR(64) no โ€” โ€” โ€”
provider VARCHAR(100) yes โ€” โ€” โ€”
is_active BOOLEAN yes โ€” โ€” โ€”
created_at TIMESTAMPTZ no NOW() โ€” โ€”
updated_at TIMESTAMPTZ no NOW() โ€” โ€”

Indexes: idx_org_ips_org(org_id, is_active)

people

  • 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 โ€” โ€” โ€”
branch_id UUID yes โ€” FK branches.id
user_id UUID yes โ€” โ€” โ€”
first_name VARCHAR(255) no โ€” โ€” โ€”
last_name VARCHAR(255) yes โ€” โ€” โ€”
email VARCHAR(255) yes โ€” โ€” โ€”
phone VARCHAR(255) yes โ€” โ€” โ€”
mobile VARCHAR(255) yes โ€” โ€” โ€”
job_title VARCHAR(255) yes โ€” โ€” โ€”
department VARCHAR(255) yes โ€” โ€” โ€”
manager_id UUID yes โ€” FK people.id
office_location VARCHAR(255) yes โ€” โ€” โ€”
hire_date VARCHAR(255) yes โ€” โ€” โ€”
birthday VARCHAR(255) yes โ€” โ€” โ€”
avatar_url TEXT yes โ€” โ€” โ€”
bio TEXT yes โ€” โ€” โ€”
skills TEXT[] no '{}' โ€” โ€”
social_links JSONB no '{}' โ€” โ€”
custom_fields JSONB no '{}' โ€” โ€”
timezone VARCHAR(255) yes โ€” โ€” โ€”
locale VARCHAR(255) yes โ€” โ€” โ€”
is_active BOOLEAN no TRUE โ€” โ€”
last_seen_at TIMESTAMPTZ yes โ€” โ€” โ€”
created_at TIMESTAMPTZ no NOW() โ€” โ€”
updated_at TIMESTAMPTZ no NOW() โ€” โ€”

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