Maverick Docs
Technical Reference

Database Schema

Every table, column, index, and constraint from SQL migrations

82 migrations | 64 tables | 238 indexes

Migrations

#FileTables
001001_create_core_tables.sqluser_workspace_access, client_registry, client_settings, client_pricing, client_costs, monthly_revenue_snapshots, client_zipcodes
002002_create_contact_pipeline.sqlraw_contacts, verified_contacts, weekly_batches, upload_audit_log, debounce_usage
003003_create_scraping_jobs.sqlscraping_jobs, scraping_job_logs, agent_runs, agent_errors, site_credentials
004004_create_lead_management.sqlclient_leads
005005_create_email_infrastructure.sqlemail_accounts, email_account_metadata, email_account_polling
006006_create_user_profiles.sqluser_profiles
006006_optimize_raw_contacts.sql(alter/index only)
007007_fix_raw_contacts_schema.sql(alter/index only)
008008_create_filter_rules.sqlclient_filter_rules
009009_add_missing_verified_fields.sql(alter/index only)
010010_create_default_filter_rules.sql(alter/index only)
011011_add_email_bison_workspace_mapping.sql(alter/index only)
012012_add_bison_campaign_id.sql(alter/index only)
013013_create_vault_functions.sql(alter/index only)
014014_update_site_credentials_schema.sql(alter/index only)
015015_create_credential_audit_log.sqlcredential_audit_log
016016_create_scraping_job_batches.sqlscraping_job_batches
017017_create_campaign_metrics.sqlcampaign_metrics
018018_add_duplicate_detection_indexes.sql(alter/index only)
018018_create_debounce_bulk_jobs.sqldebounce_bulk_jobs
019019_add_credential_to_jobs.sql(alter/index only)
020020_create_task_progress_tables.sqlfiltering_tasks, verification_tasks
021021_add_workspace_contact_fields.sql(alter/index only)
022022_tighten_rls_policies.sql(alter/index only)
023023_create_pipeline_runs.sqlpipeline_runs
024024_add_month_filter_to_stats.sql(alter/index only)
025025_add_upload_status_to_verified_contacts.sql(alter/index only)
026026_update_pipeline_stats_with_upload_status.sql(alter/index only)
027027_email_bison_account_sync.sql(alter/index only)
028028_campaign_metrics_progress.sql(alter/index only)
029029_client_leads_bison_sync.sql(alter/index only)
030030_client_targets.sqlclient_targets
031031_crm_webhook_integration.sqlcrm_delivery_log, slack_notifications_sent, lead_replies, webhook_delivery_log, webhook_health
032032_master_contacts_integration.sqlhome_value_codes
033033_campaign_crm_routing.sqlcampaign_crm_routing
034034_add_csv_processing_status.sql(alter/index only)
035035_add_month_leading_indexes.sql(alter/index only)
035035_create_tasks_table.sqltasks
035035_reply_response_tracking.sql(alter/index only)
036036_auto_reply_config.sqlauto_reply_config, auto_reply_log
037037_thomas_migration_compat.sqlreply_templates, sent_replies, sma_policies, client_metrics, monthly_daily_revenue_history
038038_add_bounce_alert_throttle.sql(alter/index only)
038038_daily_revenue_unique_index.sql(alter/index only)
039039_extra_data_and_bison_field_mapping.sql(alter/index only)
039039_unique_workspace_lead_email.sql(alter/index only)
040040_add_source_type_to_contact_stats.sql(alter/index only)
041041_backfill_source_type_scraped.sql(alter/index only)
041041_bison_source_of_truth.sql(alter/index only)
042042_pipeline_stats_all_months.sql(alter/index only)
042042_workspace_stats_cache.sqlworkspace_stats_cache
043043_analyze_and_index_for_performance.sql(alter/index only)
044044_pipeline_stats_cache_table.sqlpipeline_stats_cache
045045_workspace_daily_stats.sqlworkspace_daily_stats
046046_backfill_client_type.sql(alter/index only)
047047_mx_checked_at.sql(alter/index only)
048048_infrastructure_orders.sqlreseller_configs, infrastructure_orders, infrastructure_order_events
049049_normalize_pipeline_stages.sql(alter/index only)
050050_sma_policies_rls.sql(alter/index only)
051051_workspace_access_rls_helper.sql(alter/index only)
052052_onboarding_drafts.sqlonboarding_drafts
053053_agent_conversations.sqlagent_threads, agent_messages
054054_infrastructure_action_items_rpc.sql(alter/index only)
055055_fix_warmup_disabled_count.sql(alter/index only)
056056_fix_action_items_jsonb_cast.sql(alter/index only)
057057_fix_reseller_warmup_periods.sql(alter/index only)
058058_domain_tracking.sql(alter/index only)
059059_task_events.sqltask_events
060060_hall_of_fame.sqlhall_of_fame_nominations, hall_of_fame_votes
060060_tasks_v2.sqltask_activity
062062_increment_daily_interested.sql(alter/index only)
063063_normalize_contact_names_trigger.sql(alter/index only)
064064_reply_ai_upgrade.sqlai_generation_log, prompt_eval_results
064064_week_bucket_not_null.sql(alter/index only)
065065_crm_destinations.sqlcrm_destinations
065065_reply_templates_unique_workspace.sql(alter/index only)
066066_crm_routing_flag.sql(alter/index only)
067067_burnt_domains_root_domain_grouping.sql(alter/index only)
068068_dedup_aggregation_functions.sql(alter/index only)
069069_client_registry_excluded_zips.sql(alter/index only)
070070_zip_inclusion_mode.sql(alter/index only)
071071_raw_contacts_bypass_routing.sql(alter/index only)
072072_resources.sqlresources, resource_requests

Tables

user_workspace_access

Multi-tenant user access control - maps users to workspaces with roles

Defined in: 001_create_core_tables.sql

ColumnTypeConstraints
idUUIDPRIMARY KEY DEFAULT gen_random_uuid()
user_idUUIDNOT NULL REFERENCES auth.users(id) ON DELETE CASCADE
workspace_nameTEXTNOT NULL
roleTEXTNOT NULL CHECK (role IN ('admin', 'client', 'viewer'))
created_atTIMESTAMPTZDEFAULT NOW()
updated_atTIMESTAMPTZDEFAULT NOW()

client_registry

Master client registry - single source of truth for all client data

Defined in: 001_create_core_tables.sql

ColumnTypeConstraints
workspace_idSERIALPRIMARY KEY
workspace_nameTEXTNOT NULL UNIQUE
display_nameTEXT
is_activeBOOLEANDEFAULT true
billing_typeTEXTCHECK (billing_type IN ('per_lead', 'retainer'))
price_per_leadDECIMAL(10,2)DEFAULT 0.00
retainer_amountDECIMAL(10,2)DEFAULT 0.00
monthly_kpi_targetINTEGERDEFAULT 0
monthly_contact_targetINTEGERDEFAULT 0
contact_tierTEXTCHECK (contact_tier IN ('100_leads', '200_leads', 'custom'))
daily_sending_targetINTEGERDEFAULT 0
bison_workspace_idINTEGER
bison_api_keyTEXT
bison_instanceTEXT
agency_colorTEXT
airtable_record_idTEXT
client_typeTEXTDEFAULT 'home_insurance'
slack_webhook_urlTEXT
notesTEXT
created_atTIMESTAMPTZDEFAULT NOW()
updated_atTIMESTAMPTZDEFAULT NOW()

client_settings

Defined in: 001_create_core_tables.sql

ColumnTypeConstraints
idSERIALPRIMARY KEY
workspace_nameTEXTUNIQUE REFERENCES public.client_registry(workspace_name) ON DELETE CASCADE
settingsJSONBDEFAULT ''::jsonb
created_atTIMESTAMPTZDEFAULT NOW()
updated_atTIMESTAMPTZDEFAULT NOW()

client_pricing

Defined in: 001_create_core_tables.sql

ColumnTypeConstraints
idSERIALPRIMARY KEY
workspace_nameTEXTUNIQUE REFERENCES public.client_registry(workspace_name) ON DELETE CASCADE
billing_typeTEXTCHECK (billing_type IN ('per_lead', 'retainer'))
price_per_leadDECIMAL(10,2)DEFAULT 0.00
retainer_amountDECIMAL(10,2)DEFAULT 0.00
effective_dateDATEDEFAULT CURRENT_DATE
created_atTIMESTAMPTZDEFAULT NOW()

client_costs

Defined in: 001_create_core_tables.sql

ColumnTypeConstraints
idSERIALPRIMARY KEY
workspace_nameTEXTREFERENCES public.client_registry(workspace_name) ON DELETE CASCADE
monthTEXTNOT NULL
email_account_costsDECIMAL(10,2)DEFAULT 0.00
labor_costsDECIMAL(10,2)DEFAULT 0.00
other_costsDECIMAL(10,2)DEFAULT 0.00
total_costsDECIMAL(10,2)GENERATED ALWAYS AS (email_account_costs + labor_costs + other_costs) STORED
created_atTIMESTAMPTZDEFAULT NOW()

monthly_revenue_snapshots

Defined in: 001_create_core_tables.sql

ColumnTypeConstraints
idSERIALPRIMARY KEY
workspace_nameTEXTREFERENCES public.client_registry(workspace_name) ON DELETE CASCADE
monthTEXTNOT NULL
billable_leadsINTEGERDEFAULT 0
per_lead_revenueDECIMAL(10,2)DEFAULT 0.00
retainer_revenueDECIMAL(10,2)DEFAULT 0.00
total_revenueDECIMAL(10,2)GENERATED ALWAYS AS (per_lead_revenue + retainer_revenue) STORED
snapshot_dateDATEDEFAULT CURRENT_DATE
created_atTIMESTAMPTZDEFAULT NOW()

client_zipcodes

ZIP code assignments by client and month

Defined in: 001_create_core_tables.sql

ColumnTypeConstraints
idSERIALPRIMARY KEY
workspace_nameTEXTREFERENCES public.client_registry(workspace_name) ON DELETE CASCADE
zip_codeTEXTNOT NULL
stateTEXTNOT NULL
monthTEXTNOT NULL, -- "2025-11" or "active" for staging
assigned_atTIMESTAMPTZDEFAULT NOW()
created_atTIMESTAMPTZDEFAULT NOW()

raw_contacts

Raw contact uploads from Xpressdocs/Cole X Dates before processing

Defined in: 002_create_contact_pipeline.sql

ColumnTypeConstraints
idBIGSERIALPRIMARY KEY
upload_batch_idUUIDNOT NULL DEFAULT gen_random_uuid()
workspace_nameTEXTREFERENCES public.client_registry(workspace_name)
monthTEXTNOT NULL
uploaded_byTEXT
uploaded_atTIMESTAMPTZDEFAULT NOW()
scraping_job_idUUID
zip_codeTEXT
stateTEXT
first_nameTEXT
last_nameTEXT
emailTEXTNOT NULL
phoneTEXT
mailing_addressTEXT
mailing_cityTEXT
mailing_stateTEXT
mailing_zipTEXT
property_addressTEXT
property_cityTEXT
property_stateTEXT
property_zipTEXT
home_value_estimateDECIMAL(12,2)
purchase_dateDATE
processing_statusTEXTDEFAULT 'pending' CHECK (processing_status IN ('pending', 'filtered_out', 'ready_for_verification', 'verified', 'failed'))
is_head_of_householdBOOLEANDEFAULT false
meets_value_criteriaBOOLEANDEFAULT false
is_high_net_worthBOOLEANDEFAULT false
parsed_purchase_dateDATE
filter_reasonTEXT
processed_atTIMESTAMPTZ
created_atTIMESTAMPTZDEFAULT NOW()

verified_contacts

Email-verified contacts ready for weekly batch uploads

Defined in: 002_create_contact_pipeline.sql

ColumnTypeConstraints
idBIGSERIALPRIMARY KEY
raw_contact_idBIGINTREFERENCES public.raw_contacts(id) ON DELETE CASCADE
workspace_nameTEXTNOT NULL REFERENCES public.client_registry(workspace_name)
monthTEXTNOT NULL
first_nameTEXT
last_nameTEXT
emailTEXTNOT NULL
property_addressTEXT
property_cityTEXT
property_stateTEXT
property_zipTEXT
home_value_estimateDECIMAL(12,2)
purchase_dateDATE
purchase_dayINTEGER
renewal_start_dateDATE
renewal_end_dateDATE
week_bucketINTEGERCHECK (week_bucket BETWEEN 1 AND 4)
debounce_statusTEXTCHECK (debounce_status IN ('deliverable', 'undeliverable', 'risky', 'unknown', 'pending'))
debounce_responseJSONB
debounce_verified_atTIMESTAMPTZ
debounce_credits_usedINTEGERDEFAULT 1
is_high_net_worthBOOLEANDEFAULT false
target_campaignTEXT
is_uploadedBOOLEANDEFAULT false
upload_batch_idUUID
uploaded_atTIMESTAMPTZ
created_atTIMESTAMPTZDEFAULT NOW()
updated_atTIMESTAMPTZDEFAULT NOW()

weekly_batches

Tracks each weekly batch upload to Email Bison (every Monday)

Defined in: 002_create_contact_pipeline.sql

ColumnTypeConstraints
batch_idUUIDPRIMARY KEY DEFAULT gen_random_uuid()
workspace_nameTEXTNOT NULL REFERENCES public.client_registry(workspace_name)
monthTEXTNOT NULL
week_numberINTEGERNOT NULL CHECK (week_number BETWEEN 1 AND 4)
week_bucketINTEGERNOT NULL CHECK (week_bucket BETWEEN 1 AND 4)
scheduled_upload_dateDATENOT NULL
actual_upload_dateDATE
contact_countINTEGERDEFAULT 0
hnw_countINTEGERDEFAULT 0
csv_file_pathTEXT
csv_generated_atTIMESTAMPTZ
bison_upload_idTEXT
bison_campaign_nameTEXT
bison_upload_statusTEXTDEFAULT 'pending' CHECK (bison_upload_status IN ('pending', 'uploaded', 'added_to_campaign', 'failed'))
bison_error_messageTEXT
slack_notification_sentBOOLEANDEFAULT false
slack_message_tsTEXT
slack_approved_byTEXT
slack_approved_atTIMESTAMPTZ
created_atTIMESTAMPTZDEFAULT NOW()
updated_atTIMESTAMPTZDEFAULT NOW()

upload_audit_log

Complete audit trail of all automated pipeline operations

Defined in: 002_create_contact_pipeline.sql

ColumnTypeConstraints
idBIGSERIALPRIMARY KEY
batch_idUUIDREFERENCES public.weekly_batches(batch_id) ON DELETE CASCADE
workspace_nameTEXTNOT NULL
monthTEXTNOT NULL
actionTEXTNOT NULL CHECK (action IN ('csv_upload', 'contact_verification', 'batch_generation', 'bison_upload', 'campaign_add', 'campaign_rename', 'slack_notification'))
statusTEXTNOT NULL CHECK (status IN ('success', 'partial_success', 'failed'))
contacts_processedINTEGERDEFAULT 0
contacts_succeededINTEGERDEFAULT 0
contacts_failedINTEGERDEFAULT 0
api_endpointTEXT
api_requestJSONB
api_responseJSONB
error_detailsJSONB
duration_msINTEGER
credits_usedINTEGER
performed_byTEXTDEFAULT 'system'
performed_atTIMESTAMPTZDEFAULT NOW()

debounce_usage

Tracks Debounce API credit usage for billing and monitoring

Defined in: 002_create_contact_pipeline.sql

ColumnTypeConstraints
idBIGSERIALPRIMARY KEY
monthTEXTNOT NULL
workspace_nameTEXT
batch_idUUIDREFERENCES public.weekly_batches(batch_id)
credits_usedINTEGERNOT NULL DEFAULT 0
emails_verifiedINTEGERNOT NULL DEFAULT 0
deliverable_countINTEGERDEFAULT 0
undeliverable_countINTEGERDEFAULT 0
risky_countINTEGERDEFAULT 0
unknown_countINTEGERDEFAULT 0
verified_atTIMESTAMPTZDEFAULT NOW()

scraping_jobs

Tracks Xpressdocs scraping jobs with status and results

Defined in: 003_create_scraping_jobs.sql

ColumnTypeConstraints
job_idUUIDPRIMARY KEY DEFAULT gen_random_uuid()
workspace_nameTEXTREFERENCES public.client_registry(workspace_name)
job_typeTEXTDEFAULT 'xpressdocs_scrape'
stateTEXTNOT NULL
zip_codesTEXT[]NOT NULL
monthTEXTNOT NULL
list_typeTEXTDEFAULT 'Emailing'
statusTEXTDEFAULT 'pending' CHECK (status IN ('pending', 'running', 'completed', 'failed', 'limit_exceeded', 'cancelled'))
progressINTEGERDEFAULT 0
total_zipsINTEGER
processed_zipsINTEGERDEFAULT 0
records_downloadedINTEGERDEFAULT 0
csv_filesTEXT[]
error_messageTEXT
celery_task_idTEXT
started_atTIMESTAMPTZ
completed_atTIMESTAMPTZ
created_atTIMESTAMPTZDEFAULT NOW()
updated_atTIMESTAMPTZDEFAULT NOW()

scraping_job_logs

Detailed logs for each step of a scraping job

Defined in: 003_create_scraping_jobs.sql

ColumnTypeConstraints
idBIGSERIALPRIMARY KEY
job_idUUIDREFERENCES public.scraping_jobs(job_id) ON DELETE CASCADE
stepTEXTNOT NULL
statusTEXTNOT NULL
messageTEXT
zip_codesTEXT[]
records_countINTEGER
logged_atTIMESTAMPTZDEFAULT NOW()

agent_runs

Tracks all automation workflow executions

Defined in: 003_create_scraping_jobs.sql

ColumnTypeConstraints
run_idUUIDPRIMARY KEY DEFAULT gen_random_uuid()
workflowTEXTNOT NULL
client_idINTEGERREFERENCES public.client_registry(workspace_id)
siteTEXT
statusTEXTDEFAULT 'running' CHECK (status IN ('running', 'success', 'failed', 'partial'))
started_atTIMESTAMPTZDEFAULT NOW()
finished_atTIMESTAMPTZ
metricsJSONB
trace_urlTEXT
errorTEXT
created_atTIMESTAMPTZDEFAULT NOW()
updated_atTIMESTAMPTZDEFAULT NOW()

agent_errors

Detailed error tracking with screenshots and traces

Defined in: 003_create_scraping_jobs.sql

ColumnTypeConstraints
idBIGSERIALPRIMARY KEY
run_idUUIDREFERENCES public.agent_runs(run_id) ON DELETE CASCADE
stepTEXTNOT NULL
error_typeTEXTNOT NULL
messageTEXTNOT NULL
stack_traceTEXT
screenshot_urlTEXT
trace_urlTEXT
contextJSONB
retry_countINTEGERDEFAULT 0
resolvedBOOLEANDEFAULT false
resolved_atTIMESTAMPTZ
created_atTIMESTAMPTZDEFAULT NOW()

site_credentials

Secure credential storage for external sites

Defined in: 003_create_scraping_jobs.sql

ColumnTypeConstraints
idSERIALPRIMARY KEY
siteTEXTNOT NULL
usernameTEXTNOT NULL
secret_refTEXTNOT NULL
state_coverageTEXT[]
mfa_typeTEXT
last_verified_atTIMESTAMPTZ
notesTEXT
created_atTIMESTAMPTZDEFAULT NOW()
updated_atTIMESTAMPTZDEFAULT NOW()

client_leads

Client portal leads with pipeline management

Defined in: 004_create_lead_management.sql

ColumnTypeConstraints
idUUIDPRIMARY KEY DEFAULT gen_random_uuid()
workspace_nameTEXTNOT NULL
lead_emailTEXT
first_nameTEXT
last_nameTEXT
phoneTEXT
addressTEXT
cityTEXT
stateTEXT
zipTEXT
date_receivedTIMESTAMPTZ
reply_receivedTEXT
email_sentTEXT
email_subjectTEXT
lead_valueDECIMAL(10,2)DEFAULT 500.00
renewal_dateTEXT
birthdayTEXT
campaign_nameTEXT
sender_emailTEXT
icpBOOLEANDEFAULT false
pipeline_stageTEXTDEFAULT 'new'
pipeline_positionINTEGERDEFAULT 0
interestedBOOLEANDEFAULT false
notesTEXT
premium_amountDECIMAL(10,2)
policy_typeTEXT
bison_conversation_urlTEXT
bison_lead_idTEXT
reply_uuidTEXT
custom_variablesJSONB
tagsTEXT[]
airtable_idTEXTUNIQUE
deleted_atTIMESTAMPTZ
created_atTIMESTAMPTZDEFAULT NOW()
updated_atTIMESTAMPTZDEFAULT NOW()
last_synced_atTIMESTAMPTZDEFAULT NOW()

email_accounts

Email account inventory with health and capacity tracking

Defined in: 005_create_email_infrastructure.sql

ColumnTypeConstraints
idSERIALPRIMARY KEY
email_addressTEXTUNIQUE NOT NULL
workspace_nameTEXTREFERENCES public.client_registry(workspace_name)
statusTEXTDEFAULT 'active'
health_scoreINTEGERDEFAULT 100
daily_sending_limitINTEGERDEFAULT 50
volume_per_accountINTEGERDEFAULT 0
providerTEXT
notesTEXT
created_atTIMESTAMPTZDEFAULT NOW()
updated_atTIMESTAMPTZDEFAULT NOW()

email_account_metadata

Daily performance metrics for email accounts

Defined in: 005_create_email_infrastructure.sql

ColumnTypeConstraints
idSERIALPRIMARY KEY
email_account_idINTEGERREFERENCES public.email_accounts(id) ON DELETE CASCADE
sent_countINTEGERDEFAULT 0
delivered_countINTEGERDEFAULT 0
bounce_rateDECIMAL(5,2)
spam_rateDECIMAL(5,2)
metric_dateDATENOT NULL
created_atTIMESTAMPTZDEFAULT NOW()

email_account_polling

Tracks email account polling job status

Defined in: 005_create_email_infrastructure.sql

ColumnTypeConstraints
idSERIALPRIMARY KEY
last_poll_atTIMESTAMPTZ
next_poll_atTIMESTAMPTZ
statusTEXTDEFAULT 'idle'
error_messageTEXT
created_atTIMESTAMPTZDEFAULT NOW()
updated_atTIMESTAMPTZDEFAULT NOW()

user_profiles

Extended user profile information linked to auth.users

Defined in: 006_create_user_profiles.sql

ColumnTypeConstraints
idUUIDPRIMARY KEY REFERENCES auth.users(id) ON DELETE CASCADE
emailTEXTNOT NULL UNIQUE
full_nameTEXT
avatar_urlTEXT
phoneTEXT
default_workspace_nameTEXTREFERENCES public.client_registry(workspace_name) ON DELETE SET NULL
is_activeBOOLEANDEFAULT true
email_verifiedBOOLEANDEFAULT false
last_login_atTIMESTAMPTZ
login_countINTEGERDEFAULT 0
metadataJSONBDEFAULT ''::jsonb
created_atTIMESTAMPTZDEFAULT NOW()
updated_atTIMESTAMPTZDEFAULT NOW()

client_filter_rules

Client-specific filter rules applied before email verification

Defined in: 008_create_filter_rules.sql

ColumnTypeConstraints
idUUIDPRIMARY KEY DEFAULT gen_random_uuid()
workspace_nameTEXTNOT NULL REFERENCES public.client_registry(workspace_name) ON DELETE CASCADE
rule_nameTEXTNOT NULL
priorityINTEGERNOT NULL DEFAULT 100, -- Lower number = higher priority
is_activeBOOLEANDEFAULT true
field_nameTEXTNOT NULL, -- Column name in raw_contacts
operatorTEXTNOT NULL CHECK (operator IN (
valueJSONBNOT NULL, -- Expected value (can be string, number, array)
actionTEXTNOT NULL CHECK (action IN ('require', 'reject')), -- What to do if rule matches
created_atTIMESTAMPTZDEFAULT NOW()
updated_atTIMESTAMPTZDEFAULT NOW()

credential_audit_log

Audit trail for all credential management actions

Defined in: 015_create_credential_audit_log.sql

ColumnTypeConstraints
idBIGSERIALPRIMARY KEY
credential_idINTEGERREFERENCES public.site_credentials(id) ON DELETE SET NULL
actionTEXTNOT NULL CHECK (action IN ('created', 'updated', 'deleted', 'tested', 'password_changed', 'accessed'))
performed_byUUIDREFERENCES auth.users(id) ON DELETE SET NULL
ip_addressTEXT
user_agentTEXT
detailsJSONBDEFAULT ''::jsonb
previous_stateJSONB
new_stateJSONB
successBOOLEANDEFAULT true
error_messageTEXT
created_atTIMESTAMPTZDEFAULT NOW()

scraping_job_batches

Child table for scraping_jobs. Each batch represents one state being scraped in parallel. Enables 3-5x speedup via concurrent worker execution.

Defined in: 016_create_scraping_job_batches.sql

ColumnTypeConstraints
idBIGSERIALPRIMARY KEY
job_idUUIDNOT NULL REFERENCES public.scraping_jobs(job_id) ON DELETE CASCADE
batch_numberINTNOT NULL
stateTEXTNOT NULL
zip_codesTEXT[]NOT NULL
monthTEXTNOT NULL
list_typeTEXTNOT NULL
workspace_nameTEXTNOT NULL
credential_idINTREFERENCES public.site_credentials(id)
statusTEXTNOT NULL DEFAULT 'pending'
celery_task_idTEXTUNIQUE
csv_file_pathTEXT
record_countINTDEFAULT 0
split_countINTDEFAULT 0, -- Number of times batch was split due to 10K limit
created_atTIMESTAMPTZNOT NULL DEFAULT NOW()
started_atTIMESTAMPTZ
completed_atTIMESTAMPTZ
duration_secondsINT
retry_countINTDEFAULT 0
max_retriesINTDEFAULT 3
error_messageTEXT
error_typeTEXT,-- 'browser_crash', 'timeout', 'auth_failure', 'network_error'
browser_profileTEXT,-- Chromium profile used
ip_addressTEXT,-- For debugging geolocation issues

campaign_metrics

Stores performance metrics synced from Email Bison campaigns

Defined in: 017_create_campaign_metrics.sql

ColumnTypeConstraints
idBIGSERIALPRIMARY KEY
batch_idUUIDREFERENCES public.weekly_batches(batch_id) ON DELETE CASCADE
email_bison_campaign_idTEXTNOT NULL
emails_sentINTDEFAULT 0
emails_deliveredINTDEFAULT 0
emails_bouncedINTDEFAULT 0
emails_openedINTDEFAULT 0
emails_clickedINTDEFAULT 0
emails_repliedINTDEFAULT 0
unsubscribedINTDEFAULT 0
open_rateFLOATDEFAULT 0.0
click_rateFLOATDEFAULT 0.0
reply_rateFLOATDEFAULT 0.0
synced_atTIMESTAMPTZDEFAULT NOW()
created_atTIMESTAMPTZDEFAULT NOW()

debounce_bulk_jobs

Tracks bulk email verification jobs submitted to Debounce Bulk API. Enables 10-100x faster verification compared to sequential API calls. Auto-used when batch_size > 50 emails.

Defined in: 018_create_debounce_bulk_jobs.sql

ColumnTypeConstraints
idBIGSERIALPRIMARY KEY
job_idUUIDUNIQUE DEFAULT gen_random_uuid()
workspace_nameTEXTNOT NULL REFERENCES public.client_registry(workspace_name)
monthTEXTNOT NULL
debounce_list_idTEXTUNIQUE, -- From Debounce API response
debounce_list_nameTEXT
upload_csv_urlTEXTNOT NULL, -- Public URL we sent to Debounce
result_csv_urlTEXT,-- CDN URL from Debounce
storage_pathTEXT,-- Our storage path for cleanup
statusTEXTNOT NULL DEFAULT 'uploading'
percentageINTDEFAULT 0, -- Processing progress (0-100)
total_emailsINTNOT NULL
processed_emailsINTDEFAULT 0
deliverable_countINTDEFAULT 0
undeliverable_countINTDEFAULT 0
risky_countINTDEFAULT 0
unknown_countINTDEFAULT 0
created_atTIMESTAMPTZDEFAULT NOW()
submitted_atTIMESTAMPTZ,-- When sent to Debounce
completed_atTIMESTAMPTZ
downloaded_atTIMESTAMPTZ,-- When results downloaded
error_messageTEXT
retry_countINTDEFAULT 0
max_retriesINTDEFAULT 3
credits_usedINT

filtering_tasks

Tracks filtering task progress for real-time SSE updates to frontend

Defined in: 020_create_task_progress_tables.sql

ColumnTypeConstraints
task_idTEXTPRIMARY KEY
workspace_nameTEXTNOT NULL REFERENCES public.client_registry(workspace_name)
statusTEXTNOT NULL DEFAULT 'pending'
totalINTEGERNOT NULL DEFAULT 0
processedINTEGERNOT NULL DEFAULT 0
passedINTEGERNOT NULL DEFAULT 0
filtered_outINTEGERNOT NULL DEFAULT 0
source_statusTEXTNOT NULL DEFAULT 'pending'
batch_sizeINTEGERNOT NULL DEFAULT 1000
errorTEXT
started_atTIMESTAMPTZ
completed_atTIMESTAMPTZ
created_atTIMESTAMPTZNOT NULL DEFAULT NOW()
updated_atTIMESTAMPTZNOT NULL DEFAULT NOW()

verification_tasks

Tracks verification task progress for real-time SSE updates to frontend

Defined in: 020_create_task_progress_tables.sql

ColumnTypeConstraints
task_idTEXTPRIMARY KEY
workspace_nameTEXTNOT NULL REFERENCES public.client_registry(workspace_name)
statusTEXTNOT NULL DEFAULT 'pending'
methodTEXTNOT NULL DEFAULT 'sequential'
totalINTEGERNOT NULL DEFAULT 0
processedINTEGERNOT NULL DEFAULT 0
verifiedINTEGERNOT NULL DEFAULT 0
invalidINTEGERNOT NULL DEFAULT 0
unknownINTEGERNOT NULL DEFAULT 0
bulk_job_idTEXT
debounce_statusTEXT
batch_sizeINTEGERNOT NULL DEFAULT 100
errorTEXT
started_atTIMESTAMPTZ
completed_atTIMESTAMPTZ
created_atTIMESTAMPTZNOT NULL DEFAULT NOW()
updated_atTIMESTAMPTZNOT NULL DEFAULT NOW()

pipeline_runs

Tracks complete pipeline executions from sourcing to Email Bison upload

Defined in: 023_create_pipeline_runs.sql

ColumnTypeConstraints
idSERIALPRIMARY KEY
run_idUUIDDEFAULT gen_random_uuid() UNIQUE NOT NULL
workspace_nameTEXTNOT NULL REFERENCES client_registry(workspace_name)
monthTEXTNOT NULL, -- YYYY-MM format
sourceTEXTNOT NULL DEFAULT 'scraper', -- 'scraper', 'master_db', 'csv_upload'
target_volumeINTEGER
stateTEXT
zip_codesTEXT[],-- Array of ZIP codes
statusTEXTNOT NULL DEFAULT 'pending', -- pending, running, completed, failed, cancelled
current_stageTEXTDEFAULT 'init', -- init, scraping, processing, filtering, verifying, batching, uploading, completed
stage_countsJSONBDEFAULT ''::jsonb
started_atTIMESTAMPTZ
completed_atTIMESTAMPTZ
error_messageTEXT
error_stageTEXT
celery_task_idsJSONBDEFAULT ''::jsonb
created_atTIMESTAMPTZDEFAULT NOW()
updated_atTIMESTAMPTZDEFAULT NOW()
created_byUUIDREFERENCES auth.users(id)

client_targets

Monthly KPI targets and progress tracking for Gap-to-Goal dashboard

Defined in: 030_client_targets.sql

ColumnTypeConstraints
idSERIALPRIMARY KEY
workspace_nameTEXTNOT NULL REFERENCES public.client_registry(workspace_name)
monthTEXTNOT NULL, -- YYYY-MM format
contact_volume_targetINTEGERDEFAULT 0
email_volume_targetINTEGERDEFAULT 0
lead_targetINTEGERDEFAULT 0
revenue_targetNUMERIC(10,2)DEFAULT 0
contacts_uploadedINTEGERDEFAULT 0
emails_sentINTEGERDEFAULT 0
leads_generatedINTEGERDEFAULT 0
revenue_actualNUMERIC(10,2)DEFAULT 0
contacts_gapINTEGERGENERATED ALWAYS AS (contact_volume_target - contacts_uploaded) STORED
emails_gapINTEGERGENERATED ALWAYS AS (email_volume_target - emails_sent) STORED
leads_gapINTEGERGENERATED ALWAYS AS (lead_target - leads_generated) STORED
revenue_gapNUMERIC(10,2)GENERATED ALWAYS AS (revenue_target - revenue_actual) STORED
contacts_progressNUMERIC(5,2)GENERATED ALWAYS AS (
CASEWHENcontact_volume_target > 0
ELSE0END
emails_progressNUMERIC(5,2)GENERATED ALWAYS AS (
CASEWHENemail_volume_target > 0
ELSE0END
leads_progressNUMERIC(5,2)GENERATED ALWAYS AS (
CASEWHENlead_target > 0
ELSE0END
revenue_progressNUMERIC(5,2)GENERATED ALWAYS AS (
CASEWHENrevenue_target > 0
THENLEAST(ROUND((revenue_actual/ revenue_target * 100), 2), 999.99)
ELSE0END
targets_overriddenBOOLEANDEFAULT false
notesTEXT
last_synced_atTIMESTAMPTZ
created_atTIMESTAMPTZDEFAULT NOW()
updated_atTIMESTAMPTZDEFAULT NOW()

crm_delivery_log

Tracks all lead deliveries to external CRMs (Agency Zoom, Ricochet, etc.)

Defined in: 031_crm_webhook_integration.sql

ColumnTypeConstraints
idUUIDPRIMARY KEY DEFAULT gen_random_uuid()
workspace_nameTEXTNOT NULL
lead_emailTEXTNOT NULL
bison_lead_idTEXT
bison_reply_idTEXT
crm_typeTEXTNOT NULL, -- 'agency_zoom', 'ricochet', 'ezlynx', 'agency_mvp', 'generic'
crm_endpointTEXTNOT NULL
successBOOLEANNOT NULL DEFAULT FALSE
http_status_codeINTEGER
response_bodyTEXT
error_messageTEXT
attempt_numberINTEGERNOT NULL DEFAULT 1
max_attemptsINTEGERNOT NULL DEFAULT 3
next_retry_atTIMESTAMPTZ
request_payloadJSONB
request_headersJSONB
created_atTIMESTAMPTZNOT NULL DEFAULT NOW()
completed_atTIMESTAMPTZ

slack_notifications_sent

Deduplication table for Slack notifications

Defined in: 031_crm_webhook_integration.sql

ColumnTypeConstraints
idUUIDPRIMARY KEY DEFAULT gen_random_uuid()
reply_idTEXTNOT NULL
workspace_nameTEXTNOT NULL
notification_typeTEXTNOT NULL, -- 'client', 'global'
lead_emailTEXT
slack_webhook_urlTEXT
sent_atTIMESTAMPTZNOT NULL DEFAULT NOW()

lead_replies

Stores all Email Bison replies for live dashboard and CRM routing

Defined in: 031_crm_webhook_integration.sql

ColumnTypeConstraints
idUUIDPRIMARY KEY DEFAULT gen_random_uuid()
workspace_nameTEXTNOT NULL
lead_emailTEXTNOT NULL
first_nameTEXT
last_nameTEXT
companyTEXT
titleTEXT
phoneTEXT
reply_textTEXT
reply_dateTIMESTAMPTZNOT NULL DEFAULT NOW()
sentimentTEXTCHECK (sentiment IN ('positive', 'negative', 'neutral'))
is_interestedBOOLEANDEFAULT FALSE
confidence_scoreINTEGER
ai_reasoningTEXT
sentiment_sourceTEXTCHECK (sentiment_source IN ('ai', 'bison', 'hybrid', 'manual'))
bison_sentimentTEXT
needs_reviewBOOLEANDEFAULT FALSE
bison_lead_idTEXT
bison_reply_idTEXTUNIQUE
bison_reply_numeric_idINTEGER
bison_conversation_urlTEXT
bison_workspace_idTEXT
live_replies_enabledBOOLEANDEFAULT TRUE
crm_sent_atTIMESTAMPTZ
crm_delivery_statusTEXTCHECK (crm_delivery_status IN ('pending', 'sent', 'failed', 'retrying'))
created_atTIMESTAMPTZNOT NULL DEFAULT NOW()
updated_atTIMESTAMPTZNOT NULL DEFAULT NOW()

webhook_delivery_log

Logs all incoming Email Bison webhooks for debugging

Defined in: 031_crm_webhook_integration.sql

ColumnTypeConstraints
idUUIDPRIMARY KEY DEFAULT gen_random_uuid()
event_typeTEXTNOT NULL
workspace_nameTEXT
payloadJSONBNOT NULL
successBOOLEANNOT NULL DEFAULT FALSE
processing_time_msINTEGER
error_messageTEXT
created_atTIMESTAMPTZNOT NULL DEFAULT NOW()

webhook_health

Per-workspace webhook health metrics

Defined in: 031_crm_webhook_integration.sql

ColumnTypeConstraints
idUUIDPRIMARY KEY DEFAULT gen_random_uuid()
workspace_nameTEXTNOT NULL UNIQUE
last_webhook_atTIMESTAMPTZ
webhook_count_24hINTEGERDEFAULT 0
success_rate_24hNUMERIC(5,2)DEFAULT 100.00
is_healthyBOOLEANDEFAULT TRUE
last_error_messageTEXT
created_atTIMESTAMPTZNOT NULL DEFAULT NOW()
updated_atTIMESTAMPTZNOT NULL DEFAULT NOW()

home_value_codes

Lookup table for home value codes (A-U) to dollar amounts

Defined in: 032_master_contacts_integration.sql

ColumnTypeConstraints
codeTEXTPRIMARY KEY
min_valueINTEGER
max_valueINTEGER
midpointINTEGERNOT NULL
descriptionTEXT

campaign_crm_routing

Campaign-level CRM routing overrides for workspace defaults

Defined in: 033_campaign_crm_routing.sql

ColumnTypeConstraints
idSERIALPRIMARY KEY
campaign_idINTNOT NULL UNIQUE
campaign_nameTEXT,-- For reference/display
workspace_nameTEXTNOT NULL
crm_typeTEXT,-- 'zapier', 'agency_zoom', 'agency_mvp', etc.
external_api_urlTEXTNOT NULL, -- The webhook URL
external_api_tokenTEXT,-- If authentication needed
is_activeBOOLEANDEFAULT true
created_atTIMESTAMPTZDEFAULT NOW()
updated_atTIMESTAMPTZDEFAULT NOW()

tasks

Defined in: 035_create_tasks_table.sql

ColumnTypeConstraints
idUUIDPRIMARY KEY DEFAULT gen_random_uuid()
titleTEXTNOT NULL
descriptionTEXT
assignee_idUUIDREFERENCES public.user_profiles(id) ON DELETE SET NULL
assignee_nameTEXT,-- Denormalized for fast display
created_byUUIDNOT NULL REFERENCES public.user_profiles(id)
statusTEXTNOT NULL DEFAULT 'todo'
priorityTEXTNOT NULL DEFAULT 'medium'
categoryTEXTNOT NULL DEFAULT 'operations'
visibilityTEXTNOT NULL DEFAULT 'team'
due_dateDATE
completed_atTIMESTAMPTZ
sourceJSONBDEFAULT ''::jsonb
is_recurringBOOLEANDEFAULT false
recurring_patternTEXT
last_completedTIMESTAMPTZ
last_reminded_atTIMESTAMPTZ
created_atTIMESTAMPTZDEFAULT NOW()
updated_atTIMESTAMPTZDEFAULT NOW()

auto_reply_config

Defined in: 036_auto_reply_config.sql

ColumnTypeConstraints
idUUIDPRIMARY KEY DEFAULT gen_random_uuid()
workspace_nameTEXTNOT NULL UNIQUE
enabledBOOLEANNOT NULL DEFAULT false
toneTEXTNOT NULL DEFAULT 'professional'
min_confidence_scoreINTNOT NULL DEFAULT 70
reply_to_interestedBOOLEANNOT NULL DEFAULT true
reply_to_not_interestedBOOLEANNOT NULL DEFAULT false
reply_to_neutralBOOLEANNOT NULL DEFAULT false
skip_auto_repliesBOOLEANNOT NULL DEFAULT true
skip_bouncedBOOLEANNOT NULL DEFAULT true
max_replies_per_hourINTNOT NULL DEFAULT 20
delay_secondsINTNOT NULL DEFAULT 300
custom_instructionsTEXT
created_atTIMESTAMPTZDEFAULT now()
updated_atTIMESTAMPTZDEFAULT now()

auto_reply_log

Defined in: 036_auto_reply_config.sql

ColumnTypeConstraints
idUUIDPRIMARY KEY DEFAULT gen_random_uuid()
workspace_nameTEXTNOT NULL
lead_reply_idUUIDREFERENCES lead_replies(id)
bison_reply_numeric_idINT
lead_emailTEXT
sentimentTEXT
confidence_scoreINT
tone_usedTEXT
reply_textTEXT
model_usedTEXT
sent_successfullyBOOLEANNOT NULL DEFAULT false
skipped_reasonTEXT
error_messageTEXT
processing_time_msINT
created_atTIMESTAMPTZDEFAULT now()

reply_templates

Defined in: 037_thomas_migration_compat.sql

ColumnTypeConstraints
idSERIALPRIMARY KEY
workspace_nameTEXTNOT NULL
template_text_with_phoneTEXT
template_text_no_phoneTEXT
cc_emailsJSONBDEFAULT '[]'
special_instructionsTEXT
created_atTIMESTAMPTZDEFAULT now()
updated_atTIMESTAMPTZDEFAULT now()

sent_replies

Defined in: 037_thomas_migration_compat.sql

ColumnTypeConstraints
idSERIALPRIMARY KEY
workspace_nameTEXTNOT NULL
bison_reply_idINTEGER
reply_uuidTEXT
lead_nameTEXT
lead_emailTEXT
generated_reply_textTEXT
cc_emailsJSONBDEFAULT '[]'
sent_byTEXT
sent_atTIMESTAMPTZ
statusTEXTDEFAULT 'sent' CHECK (status IN ('pending', 'sent', 'failed', 'draft'))
error_messageTEXT
created_atTIMESTAMPTZDEFAULT now()

sma_policies

Defined in: 037_thomas_migration_compat.sql

ColumnTypeConstraints
idUUIDPRIMARY KEY DEFAULT gen_random_uuid()
workspace_nameTEXTNOT NULL
lead_idUUID
policy_typeTEXT
premium_amountDECIMAL(10,2)
agency_commissionDECIMAL(10,2)
maverick_commissionDECIMAL(10,2)
created_atTIMESTAMPTZDEFAULT now()
updated_atTIMESTAMPTZDEFAULT now()

client_metrics

Defined in: 037_thomas_migration_compat.sql

ColumnTypeConstraints
idUUIDPRIMARY KEY DEFAULT gen_random_uuid()
workspace_nameTEXTNOT NULL
metric_dateDATENOT NULL
metric_typeTEXTDEFAULT 'mtd'
emails_sentINTEGERDEFAULT 0
emails_sent_todayINTEGERDEFAULT 0
emails_sent_mtdINTEGERDEFAULT 0
emails_sent_last_7_daysINTEGERDEFAULT 0
emails_sent_last_14_daysINTEGERDEFAULT 0
emails_sent_last_30_daysINTEGERDEFAULT 0
emails_scheduled_todayINTEGERDEFAULT 0
emails_scheduled_tomorrowINTEGERDEFAULT 0
positive_repliesINTEGERDEFAULT 0
positive_replies_mtdINTEGERDEFAULT 0
positive_replies_current_monthINTEGERDEFAULT 0
positive_replies_last_7_daysINTEGERDEFAULT 0
positive_replies_last_14_daysINTEGERDEFAULT 0
positive_replies_last_30_daysINTEGERDEFAULT 0
positive_replies_last_monthINTEGERDEFAULT 0
all_replies_mtdINTEGERDEFAULT 0
bounced_mtdINTEGERDEFAULT 0
unsubscribed_mtdINTEGERDEFAULT 0
projection_emails_eomINTEGERDEFAULT 0
projection_positive_replies_eomINTEGERDEFAULT 0
mtd_leads_progressDECIMAL(5,2)DEFAULT 0
projection_replies_progressDECIMAL(5,2)DEFAULT 0
last_week_vs_week_before_progressDECIMAL(5,2)DEFAULT 0
created_atTIMESTAMPTZDEFAULT now()
updated_atTIMESTAMPTZDEFAULT now()

monthly_daily_revenue_history

Defined in: 037_thomas_migration_compat.sql

ColumnTypeConstraints
idUUIDPRIMARY KEY DEFAULT gen_random_uuid()
month_yearTEXTNOT NULL
dayINTEGERNOT NULL
dateDATE
daily_revenueDECIMAL(10,2)DEFAULT 0
cumulative_revenueDECIMAL(10,2)DEFAULT 0
lead_countINTEGERDEFAULT 0
created_atTIMESTAMPTZDEFAULT now()

workspace_stats_cache

*Pre-computed workspace KPIs rebuilt after every Bison sync. *

Defined in: 042_workspace_stats_cache.sql

ColumnTypeConstraints
idBIGSERIALPRIMARY KEY
workspace_nameTEXTNOT NULL
display_nameTEXT
stat_dateDATENOT NULL DEFAULT CURRENT_DATE
emails_sentBIGINTNOT NULL DEFAULT 0
total_leads_contactedBIGINTNOT NULL DEFAULT 0
openedBIGINTNOT NULL DEFAULT 0
unique_repliesBIGINTNOT NULL DEFAULT 0
bouncedBIGINTNOT NULL DEFAULT 0
interestedBIGINTNOT NULL DEFAULT 0
not_interestedBIGINTNOT NULL DEFAULT 0
unsubscribedBIGINTNOT NULL DEFAULT 0
open_rateNUMERIC(6,2)NOT NULL DEFAULT 0
reply_rateNUMERIC(6,2)NOT NULL DEFAULT 0
bounce_rateNUMERIC(6,2)NOT NULL DEFAULT 0
interested_percentageNUMERIC(6,2)NOT NULL DEFAULT 0
cache_typeTEXTNOT NULL DEFAULT 'current'
synced_atTIMESTAMPTZNOT NULL DEFAULT NOW()

pipeline_stats_cache

Pre-computed pipeline statistics per workspace per month. Refreshed by Celery workers after pipeline stage completions and every 5 minutes by Celery Beat.

Defined in: 044_pipeline_stats_cache_table.sql

ColumnTypeConstraints
workspace_nameTEXTNOT NULL
monthTEXTNOT NULL
total_contactsBIGINTDEFAULT 0
pendingBIGINTDEFAULT 0
filtered_outBIGINTDEFAULT 0
ready_for_verificationBIGINTDEFAULT 0
verifyingBIGINTDEFAULT 0
verifiedBIGINTDEFAULT 0
invalidBIGINTDEFAULT 0
unknownBIGINTDEFAULT 0
source_scrapedBIGINTDEFAULT 0
source_uploadedBIGINTDEFAULT 0
source_master_dbBIGINTDEFAULT 0
total_verifiedBIGINTDEFAULT 0
uploadedBIGINTDEFAULT 0
pending_uploadBIGINTDEFAULT 0
rejectedBIGINTDEFAULT 0
failedBIGINTDEFAULT 0
deliverable_countBIGINTDEFAULT 0
undeliverable_countBIGINTDEFAULT 0
risky_countBIGINTDEFAULT 0
updated_atTIMESTAMPTZDEFAULT now()

workspace_daily_stats

Daily incremental metrics per workspace from Bison chart API. Used for charts and date-filtered KPIs.

Defined in: 045_workspace_daily_stats.sql

ColumnTypeConstraints
idBIGSERIALPRIMARY KEY
workspace_nameTEXTNOT NULL
stat_dateDATENOT NULL
sentBIGINTNOT NULL DEFAULT 0
repliedBIGINTNOT NULL DEFAULT 0
interestedBIGINTNOT NULL DEFAULT 0
bouncedBIGINTNOT NULL DEFAULT 0
total_opensBIGINTNOT NULL DEFAULT 0
unique_opensBIGINTNOT NULL DEFAULT 0
unsubscribedBIGINTNOT NULL DEFAULT 0
synced_atTIMESTAMPTZNOT NULL DEFAULT NOW()

reseller_configs

Defined in: 048_infrastructure_orders.sql

ColumnTypeConstraints
idSERIALPRIMARY KEY
reseller_nameTEXTNOT NULL
display_nameTEXTNOT NULL
account_typeTEXTNOT NULL
account_type_displayTEXTNOT NULL
bison_provider_tagTEXTNOT NULL
bison_reseller_tagTEXTNOT NULL
max_send_per_dayINTEGERNOT NULL
warmup_volume_per_dayINTEGERNOT NULL
warmup_period_daysINTEGERNOT NULL
ramp_startINTEGERNOT NULL
ramp_incrementINTEGERNOT NULL
ramp_increment_interval_daysINTEGERNOT NULL DEFAULT 1
cost_per_inboxDECIMAL(10,2)
is_activeBOOLEANDEFAULT true
created_atTIMESTAMPTZDEFAULT NOW()
updated_atTIMESTAMPTZDEFAULT NOW()

infrastructure_orders

Defined in: 048_infrastructure_orders.sql

ColumnTypeConstraints
idSERIALPRIMARY KEY
workspace_nameTEXTNOT NULL REFERENCES public.client_registry(workspace_name)
reseller_config_idINTEGERNOT NULL REFERENCES public.reseller_configs(id)
quantityINTEGERNOT NULL
emails_per_inbox_per_dayINTEGERNOT NULL
stageTEXTNOT NULL DEFAULT 'order_placed'
expected_provider_tagTEXT
expected_reseller_tagTEXT
expected_date_tagTEXT
fulfilled_atTIMESTAMPTZ
fulfilled_account_countINTEGERDEFAULT 0
warmup_verified_atTIMESTAMPTZ
launch_dateDATE
ramp_started_atTIMESTAMPTZ
completed_atTIMESTAMPTZ
matched_account_idsJSONBDEFAULT '[]'::jsonb
notesTEXT
created_byTEXT
created_atTIMESTAMPTZDEFAULT NOW()
updated_atTIMESTAMPTZDEFAULT NOW()

infrastructure_order_events

Defined in: 048_infrastructure_orders.sql

ColumnTypeConstraints
idSERIALPRIMARY KEY
order_idINTEGERNOT NULL REFERENCES public.infrastructure_orders(id) ON DELETE CASCADE
from_stageTEXT
to_stageTEXTNOT NULL
event_typeTEXTNOT NULL
detailTEXT
created_byTEXT
created_atTIMESTAMPTZDEFAULT NOW()

onboarding_drafts

Defined in: 052_onboarding_drafts.sql

ColumnTypeConstraints
idUUIDDEFAULT gen_random_uuid() PRIMARY KEY
created_byUUIDREFERENCES auth.users(id)
wizard_stateJSONBNOT NULL DEFAULT ''
current_stepINTEGERNOT NULL DEFAULT 1
workspace_nameTEXT
display_nameTEXT
statusTEXTNOT NULL DEFAULT 'in_progress' CHECK (status IN ('in_progress', 'completed', 'abandoned'))
created_atTIMESTAMPTZDEFAULT NOW()
updated_atTIMESTAMPTZDEFAULT NOW()

agent_threads

Defined in: 053_agent_conversations.sql

ColumnTypeConstraints
idUUIDDEFAULT gen_random_uuid() PRIMARY KEY
user_idUUIDNOT NULL REFERENCES auth.users(id)
titleTEXT
session_idTEXT
is_archivedBOOLEANDEFAULT false
created_atTIMESTAMPTZDEFAULT NOW()
updated_atTIMESTAMPTZDEFAULT NOW()

agent_messages

Defined in: 053_agent_conversations.sql

ColumnTypeConstraints
idUUIDDEFAULT gen_random_uuid() PRIMARY KEY
thread_idUUIDNOT NULL REFERENCES agent_threads(id) ON DELETE CASCADE
roleTEXTNOT NULL CHECK (role IN ('user', 'assistant', 'system'))
contentTEXT
tool_callsJSONB
token_usageJSONB
created_atTIMESTAMPTZDEFAULT NOW()

task_events

Lightweight task event log for status page. Auto-pruned to 7 days.

Defined in: 059_task_events.sql

ColumnTypeConstraints
idSERIALPRIMARY KEY
task_idTEXTNOT NULL
task_nameTEXTNOT NULL
queueTEXT
statusTEXTNOT NULL CHECK (status IN ('started', 'succeeded', 'failed', 'retried'))
error_messageTEXT
duration_secondsFLOAT
workerTEXT
created_atTIMESTAMPTZDEFAULT NOW()

hall_of_fame_nominations

Defined in: 060_hall_of_fame.sql

ColumnTypeConstraints
idUUIDDEFAULT gen_random_uuid() PRIMARY KEY
lead_reply_idUUIDNOT NULL REFERENCES public.lead_replies(id) ON DELETE CASCADE
categoryTEXTNOT NULL CHECK (category IN ('funny', 'rude', 'wholesome', 'creative', 'unhinged'))
nominated_byTEXTNOT NULL, -- user email or 'ai_system'
nomination_sourceTEXTNOT NULL DEFAULT 'manual'
ai_confidenceINTEGER,-- 0-100, only for ai_detected
noteTEXT,-- optional comment from nominator
workspace_nameTEXTNOT NULL
lead_emailTEXTNOT NULL
reply_textTEXTNOT NULL
reply_dateTIMESTAMPTZNOT NULL
vote_countINTEGERNOT NULL DEFAULT 0, -- materialized via trigger
created_atTIMESTAMPTZDEFAULT NOW()
updated_atTIMESTAMPTZDEFAULT NOW()

hall_of_fame_votes

Defined in: 060_hall_of_fame.sql

ColumnTypeConstraints
idUUIDDEFAULT gen_random_uuid() PRIMARY KEY
nomination_idUUIDNOT NULL REFERENCES public.hall_of_fame_nominations(id) ON DELETE CASCADE
user_emailTEXTNOT NULL
created_atTIMESTAMPTZDEFAULT NOW()

task_activity

Defined in: 060_tasks_v2.sql

ColumnTypeConstraints
idUUIDPRIMARY KEY DEFAULT gen_random_uuid()
task_idUUIDNOT NULL REFERENCES public.tasks(id) ON DELETE CASCADE
event_typeTEXTNOT NULL CHECK (event_type IN (
actor_idUUIDREFERENCES public.user_profiles(id)
payloadJSONBDEFAULT ''::jsonb
created_atTIMESTAMPTZNOT NULL DEFAULT NOW()

ai_generation_log

Defined in: 064_reply_ai_upgrade.sql

ColumnTypeConstraints
idUUIDDEFAULT gen_random_uuid() PRIMARY KEY
workspace_nameTEXTNOT NULL
lead_reply_idUUID
task_typeTEXTNOT NULL
modelTEXTNOT NULL
prompt_tokensINT
completion_tokensINT
estimated_cost_usdNUMERIC(10,6)
latency_msINT
intentTEXT
toneTEXT
successBOOLEANDEFAULT TRUE
error_messageTEXT
created_atTIMESTAMPTZDEFAULT NOW()

prompt_eval_results

Defined in: 064_reply_ai_upgrade.sql

ColumnTypeConstraints
idUUIDDEFAULT gen_random_uuid() PRIMARY KEY
workspace_nameTEXTNOT NULL
eval_typeTEXTNOT NULL
total_testsINTNOT NULL
passedINTNOT NULL
failedINTNOT NULL
resultsJSONBNOT NULL
model_usedTEXT
triggered_byTEXT
created_atTIMESTAMPTZDEFAULT NOW()

crm_destinations

*Multi-destination CRM routing. Each row represents one CRM destination *

Defined in: 065_crm_destinations.sql

ColumnTypeConstraints
idSERIALPRIMARY KEY
workspace_nameTEXTNOT NULL
campaign_idINT
crm_typeTEXTNOT NULL
external_api_urlTEXTNOT NULL
external_api_tokenTEXT
crm_paramsJSONBNOT NULL DEFAULT ''::jsonb
labelTEXT
is_activeBOOLEANNOT NULL DEFAULT TRUE
created_atTIMESTAMPTZNOT NULL DEFAULT NOW()
updated_atTIMESTAMPTZNOT NULL DEFAULT NOW()

resources

*Global content library shown on the /resources page. Visible to every *

Defined in: 072_resources.sql

ColumnTypeConstraints
idUUIDPRIMARY KEY DEFAULT gen_random_uuid()
titleTEXTNOT NULL
descriptionTEXT
categoryTEXTNOT NULL
resource_typeTEXTNOT NULL
loom_urlTEXT
article_contentTEXT
pdf_storage_pathTEXT
thumbnail_urlTEXT
publishedBOOLEANNOT NULL DEFAULT TRUE
created_byUUID
created_atTIMESTAMPTZNOT NULL DEFAULT NOW()
updated_atTIMESTAMPTZNOT NULL DEFAULT NOW()
ANDarticle_contentIS NULL AND pdf_storage_path IS NULL)
ANDloom_urlIS NULL AND pdf_storage_path IS NULL)
ANDloom_urlIS NULL AND article_content IS NULL)

resource_requests

*Topic/video requests submitted by clients via the Resources page. *

Defined in: 072_resources.sql

ColumnTypeConstraints
idUUIDPRIMARY KEY DEFAULT gen_random_uuid()
requester_user_idUUIDNOT NULL
requester_emailTEXTNOT NULL
workspace_nameTEXT
topicTEXTNOT NULL
requested_formatTEXTNOT NULL
descriptionTEXT
statusTEXTNOT NULL DEFAULT 'requested'
fulfilled_resource_idUUIDREFERENCES resources(id) ON DELETE SET NULL
created_atTIMESTAMPTZNOT NULL DEFAULT NOW()
updated_atTIMESTAMPTZNOT NULL DEFAULT NOW()

Indexes

IndexTableColumns
idx_user_workspace_access_user_iduser_workspace_accessuser_id
idx_user_workspace_access_workspaceuser_workspace_accessworkspace_name
idx_user_workspace_access_roleuser_workspace_accessrole
idx_client_registry_workspace_nameclient_registryworkspace_name
idx_client_registry_activeclient_registryis_active
idx_client_registry_billing_typeclient_registrybilling_type
idx_client_settings_workspaceclient_settingsworkspace_name
idx_client_pricing_workspaceclient_pricingworkspace_name
idx_client_costs_workspace_monthclient_costsworkspace_name, month
idx_revenue_snapshots_workspace_monthmonthly_revenue_snapshotsworkspace_name, month
idx_client_zipcodes_workspaceclient_zipcodesworkspace_name
idx_client_zipcodes_stateclient_zipcodesstate
idx_client_zipcodes_monthclient_zipcodesmonth
idx_client_zipcodes_zipclient_zipcodeszip_code
idx_raw_contacts_upload_batchraw_contactsupload_batch_id
idx_raw_contacts_workspace_monthraw_contactsworkspace_name, month
idx_raw_contacts_statusraw_contactsprocessing_status
idx_raw_contacts_purchase_dateraw_contactsparsed_purchase_date
idx_raw_contacts_zipraw_contactsproperty_zip
idx_raw_contacts_scraping_jobraw_contactsscraping_job_id
idx_verified_contacts_workspace_monthverified_contactsworkspace_name, month
idx_verified_contacts_week_bucketverified_contactsweek_bucket
idx_verified_contacts_renewal_datesverified_contactsrenewal_start_date, renewal_end_date
idx_verified_contacts_upload_statusverified_contactsis_uploaded, week_bucket
idx_verified_contacts_debounce_statusverified_contactsdebounce_status
idx_verified_contacts_hnwverified_contactsis_high_net_worth
idx_weekly_batches_workspace_monthweekly_batchesworkspace_name, month
idx_weekly_batches_scheduleweekly_batchesscheduled_upload_date, bison_upload_status
idx_weekly_batches_statusweekly_batchesbison_upload_status
idx_upload_audit_batchupload_audit_logbatch_id
idx_upload_audit_workspace_monthupload_audit_logworkspace_name, month
idx_upload_audit_actionupload_audit_logaction
idx_upload_audit_statusupload_audit_logstatus
idx_upload_audit_dateupload_audit_logperformed_at DESC
idx_debounce_usage_monthdebounce_usagemonth
idx_debounce_usage_workspacedebounce_usageworkspace_name
idx_debounce_usage_datedebounce_usageverified_at DESC
idx_scraping_jobs_workspacescraping_jobsworkspace_name
idx_scraping_jobs_statusscraping_jobsstatus
idx_scraping_jobs_createdscraping_jobscreated_at DESC
idx_scraping_jobs_celery_taskscraping_jobscelery_task_id
idx_scraping_job_logs_job_idscraping_job_logsjob_id
idx_scraping_job_logs_logged_atscraping_job_logslogged_at DESC
idx_agent_runs_workflowagent_runsworkflow
idx_agent_runs_client_idagent_runsclient_id
idx_agent_runs_statusagent_runsstatus
idx_agent_runs_started_atagent_runsstarted_at DESC
idx_agent_errors_run_idagent_errorsrun_id
idx_agent_errors_stepagent_errorsstep
idx_agent_errors_typeagent_errorserror_type
idx_agent_errors_resolvedagent_errorsresolved
idx_site_credentials_sitesite_credentialssite
idx_site_credentials_usernamesite_credentialsusername
idx_client_leads_workspaceclient_leadsworkspace_name
idx_client_leads_pipelineclient_leadspipeline_stage
idx_client_leads_dateclient_leadsdate_received DESC
idx_client_leads_airtableclient_leadsairtable_id
idx_client_leads_updatedclient_leadsupdated_at DESC
idx_client_leads_emailclient_leadslead_email
idx_client_leads_interestedclient_leadsinterested
idx_client_leads_deletedclient_leadsdeleted_at
idx_email_accounts_workspaceemail_accountsworkspace_name
idx_email_accounts_statusemail_accountsstatus
idx_email_accounts_healthemail_accountshealth_score
idx_email_account_metadata_accountemail_account_metadataemail_account_id
idx_email_account_metadata_dateemail_account_metadatametric_date DESC
idx_user_profiles_emailuser_profilesemail
idx_user_profiles_default_workspaceuser_profilesdefault_workspace_name
idx_user_profiles_is_activeuser_profilesis_active
idx_user_workspace_access_activeuser_workspace_accessuser_id, workspace_name
idx_raw_contacts_workspace_statusraw_contactsworkspace_name, processing_status
idx_raw_contacts_workspace_monthraw_contactsworkspace_name, month
idx_raw_contacts_batchraw_contactsupload_batch_id
idx_raw_contacts_jobraw_contactsscraping_job_id
idx_raw_contacts_emailraw_contactsemail
idx_raw_contacts_workspace_status_monthraw_contactsworkspace_name, processing_status, month
idx_raw_contacts_email_domainraw_contactsemail_domain
idx_raw_contacts_purchase_yearraw_contactspurchase_year
idx_raw_contacts_ageraw_contactsage_years
idx_raw_contacts_dnc_landlineraw_contactsdnc_landline
idx_raw_contacts_dnc_cellraw_contactsdnc_cell
idx_raw_contacts_dobraw_contactsdate_of_birth
idx_raw_contacts_purchase_amountraw_contactspurchase_amount
idx_filter_rules_workspace_activeclient_filter_rulesworkspace_name, is_active, priority
idx_filter_rules_fieldclient_filter_rulesfield_name
idx_verified_contacts_head_of_householdverified_contactsis_head_of_household
idx_verified_contacts_email_domainverified_contactsemail_domain
idx_verified_contacts_engagementverified_contactslast_engagement_at DESC
idx_verified_contacts_campaign_targetingverified_contactsworkspace_name, is_uploaded, is_head_of_household, email_domain
idx_client_registry_email_bison_workspaceclient_registryemail_bison_workspace_id
idx_weekly_batches_bison_campaign_idweekly_batchesbison_campaign_id
idx_site_credentials_vault_secret_idsite_credentialsvault_secret_id
idx_credential_audit_credential_idcredential_audit_logcredential_id
idx_credential_audit_performed_bycredential_audit_logperformed_by
idx_credential_audit_actioncredential_audit_logaction
idx_credential_audit_created_atcredential_audit_logcreated_at DESC
idx_scraping_job_batches_job_idscraping_job_batchesjob_id
idx_scraping_job_batches_statusscraping_job_batchesstatus
idx_scraping_job_batches_workspacescraping_job_batchesworkspace_name
idx_scraping_job_batches_state_monthscraping_job_batchesstate, month
idx_scraping_job_batches_credentialscraping_job_batchescredential_id
idx_scraping_job_batches_celery_taskscraping_job_batchescelery_task_id
idx_scraping_job_batches_activescraping_job_batchesworkspace_name, status, created_at DESC
idx_campaign_metrics_batch_idcampaign_metricsbatch_id
idx_campaign_metrics_campaign_idcampaign_metricsemail_bison_campaign_id
idx_campaign_metrics_synced_atcampaign_metricssynced_at DESC
idx_raw_contacts_workspace_month_emailraw_contactsworkspace_name, month, email
idx_raw_contacts_workspace_month_addressraw_contactsworkspace_name, month, property_address
idx_debounce_bulk_workspacedebounce_bulk_jobsworkspace_name
idx_debounce_bulk_statusdebounce_bulk_jobsstatus
idx_debounce_bulk_list_iddebounce_bulk_jobsdebounce_list_id
idx_scraping_jobs_credential_usernamescraping_jobscredential_username
idx_filtering_tasks_workspacefiltering_tasksworkspace_name
idx_filtering_tasks_statusfiltering_tasksstatus
idx_filtering_tasks_createdfiltering_taskscreated_at DESC
idx_verification_tasks_workspaceverification_tasksworkspace_name
idx_verification_tasks_statusverification_tasksstatus
idx_verification_tasks_createdverification_taskscreated_at DESC
idx_verification_tasks_bulk_jobverification_tasksbulk_job_id
idx_pipeline_runs_workspacepipeline_runsworkspace_name
idx_pipeline_runs_statuspipeline_runsstatus
idx_pipeline_runs_run_idpipeline_runsrun_id
idx_pipeline_runs_created_atpipeline_runscreated_at DESC
idx_verified_contacts_upload_statusverified_contactsupload_status
idx_email_accounts_bison_idemail_accountsbison_sender_email_id
idx_email_accounts_workspace_bison_statusemail_accountsworkspace_name, bison_status
idx_email_accounts_warmup_scoreemail_accountswarmup_score
idx_email_accounts_sent_today_dateemail_accountsemails_sent_today_date
idx_campaign_metrics_statuscampaign_metricscampaign_status
idx_campaign_metrics_workspacecampaign_metricsworkspace_name
idx_campaign_metrics_completioncampaign_metricscompletion_percentage DESC
idx_campaign_metrics_workspace_statuscampaign_metricsworkspace_name, campaign_status
idx_client_leads_bison_id_intclient_leadsbison_lead_id_int
idx_client_leads_campaign_statusclient_leadsworkspace_name, lead_campaign_status
idx_client_leads_bison_campaignclient_leadsbison_campaign_id
idx_client_leads_verification_statusclient_leadsbison_verification_status
idx_client_leads_synced_atclient_leadsbison_lead_synced_at DESC
idx_client_leads_automated_replyclient_leadsis_automated_reply
idx_client_targets_workspaceclient_targetsworkspace_name
idx_client_targets_monthclient_targetsmonth DESC
idx_client_targets_workspace_monthclient_targetsworkspace_name, month
idx_client_targets_contacts_progressclient_targetscontacts_progress DESC
idx_client_targets_leads_progressclient_targetsleads_progress DESC
idx_crm_delivery_workspacecrm_delivery_logworkspace_name
idx_crm_delivery_lead_emailcrm_delivery_loglead_email
idx_crm_delivery_successcrm_delivery_logsuccess
idx_crm_delivery_createdcrm_delivery_logcreated_at
idx_crm_delivery_pending_retrycrm_delivery_lognext_retry_at
idx_slack_notifications_uniqueslack_notifications_sentreply_id, notification_type
idx_slack_notifications_workspaceslack_notifications_sentworkspace_name
idx_lead_replies_workspacelead_repliesworkspace_name
idx_lead_replies_emaillead_replieslead_email
idx_lead_replies_interestedlead_repliesis_interested
idx_lead_replies_datelead_repliesreply_date DESC
idx_lead_replies_live_enabledlead_replieslive_replies_enabled, reply_date DESC
idx_webhook_log_workspacewebhook_delivery_logworkspace_name
idx_webhook_log_eventwebhook_delivery_logevent_type
idx_webhook_log_createdwebhook_delivery_logcreated_at DESC
idx_webhook_log_failureswebhook_delivery_logsuccess
idx_webhook_health_workspacewebhook_healthworkspace_name
idx_webhook_health_unhealthywebhook_healthis_healthy
idx_raw_contacts_source_typeraw_contactssource_type
idx_raw_contacts_master_vendorraw_contactsmaster_vendor_id
idx_raw_contacts_master_dedupraw_contactsworkspace_name, month, master_vendor_id
idx_raw_contacts_home_value_coderaw_contactshome_value_code
idx_campaign_crm_routing_campaign_idcampaign_crm_routingcampaign_id
idx_campaign_crm_routing_workspacecampaign_crm_routingworkspace_name
idx_campaign_crm_routing_activecampaign_crm_routingis_active
idx_scraping_jobs_csv_processing_statusscraping_jobscsv_processing_status
idx_tasks_statustasksstatus
idx_tasks_assignee_idtasksassignee_id
idx_tasks_prioritytaskspriority
idx_tasks_due_datetasksdue_date
idx_tasks_created_bytaskscreated_by
idx_tasks_created_attaskscreated_at DESC
idx_lead_replies_response_timelead_repliesworkspace_name, our_reply_sent_at
idx_auto_reply_log_workspaceauto_reply_logworkspace_name, created_at DESC
idx_auto_reply_log_rate_limitauto_reply_logworkspace_name, sent_successfully, created_at
idx_reply_templates_workspacereply_templatesworkspace_name
idx_sent_replies_workspacesent_repliesworkspace_name, created_at DESC
idx_sent_replies_bison_replysent_repliesbison_reply_id
idx_sma_policies_workspacesma_policiesworkspace_name
idx_client_metrics_workspace_dateclient_metricsworkspace_name, metric_date DESC
idx_client_metrics_uniqueclient_metricsworkspace_name, metric_date, metric_type
idx_monthly_daily_revenue_monthmonthly_daily_revenue_historymonth_year, day
idx_workspace_metrics_last_bounce_alertworkspace_metricsworkspace_name, last_bounce_alert_at
idx_monthly_daily_revenue_uniquemonthly_daily_revenue_historymonth_year, day
idx_client_leads_workspace_emailclient_leadsworkspace_name, lead_email
idx_lead_replies_workspace_email_datelead_repliesworkspace_name, lead_email, reply_date DESC
idx_wsc_typeworkspace_stats_cachecache_type
idx_wsc_workspaceworkspace_stats_cacheworkspace_name
idx_wsc_date_descworkspace_stats_cachestat_date DESC
idx_wsc_type_wsworkspace_stats_cachecache_type, workspace_name
idx_raw_contacts_monthraw_contactsmonth
idx_verified_contacts_monthverified_contactsmonth
idx_pipeline_stats_cache_monthpipeline_stats_cachemonth
idx_wds_dateworkspace_daily_statsstat_date DESC
idx_wds_ws_dateworkspace_daily_statsworkspace_name, stat_date DESC
idx_email_accounts_mx_checkedemail_accountsmx_checked_at
idx_infra_orders_workspaceinfrastructure_ordersworkspace_name
idx_infra_orders_stageinfrastructure_ordersstage
idx_infra_orders_workspace_stageinfrastructure_ordersworkspace_name, stage
idx_order_events_orderinfrastructure_order_eventsorder_id
idx_onboarding_drafts_statusonboarding_draftsstatus
idx_onboarding_drafts_created_byonboarding_draftscreated_by
idx_agent_threads_useragent_threadsuser_id
idx_agent_threads_updatedagent_threadsupdated_at DESC
idx_agent_messages_threadagent_messagesthread_id, created_at
idx_email_accounts_domainemail_accountsdomain
idx_email_accounts_ws_domainemail_accountsworkspace_name, domain
idx_task_events_status_createdtask_eventsstatus, created_at DESC
idx_task_events_createdtask_eventscreated_at
idx_hof_nominations_categoryhall_of_fame_nominationscategory
idx_hof_nominations_vote_counthall_of_fame_nominationsvote_count DESC
idx_hof_nominations_createdhall_of_fame_nominationscreated_at DESC
idx_hof_nominations_workspacehall_of_fame_nominationsworkspace_name
idx_hof_votes_nominationhall_of_fame_votesnomination_id
idx_hof_votes_userhall_of_fame_votesuser_email
idx_tasks_source_kindtasks(source->>'kind'
idx_user_profiles_is_team_memberuser_profilesis_team_member
idx_task_activity_task_id_created_attask_activitytask_id, created_at DESC
idx_task_activity_event_typetask_activityevent_type
idx_lead_replies_intentlead_repliesintent
idx_ai_gen_log_workspaceai_generation_logworkspace_name, created_at DESC
idx_prompt_eval_workspaceprompt_eval_resultsworkspace_name, created_at DESC
uq_crm_destinations_routecrm_destinationsworkspace_name, crm_type, external_api_url, COALESCE(campaign_id, -1
idx_crm_destinations_workspacecrm_destinationsworkspace_name
idx_crm_destinations_campaigncrm_destinationscampaign_id
idx_crm_delivery_log_idempotencycrm_delivery_logbison_reply_id, destination_id
idx_crm_delivery_log_parentcrm_delivery_logparent_delivery_id
idx_client_registry_v2_routingclient_registryworkspace_name
idx_raw_contacts_workspace_month_emailraw_contactsworkspace_name, month
idx_raw_contacts_workspace_master_vendorraw_contactsworkspace_name
idx_resources_categoryresourcescategory
idx_resources_typeresourcesresource_type
idx_resources_created_atresourcescreated_at DESC
idx_resource_requests_status_createdresource_requestsstatus, created_at DESC
idx_resource_requests_requesterresource_requestsrequester_user_id, created_at DESC

Entity Relationships (Core Pipeline)

erDiagram
    client_registry ||--o{ user_workspace_access : has_users
    client_registry ||--o{ scraping_jobs : runs
    client_registry ||--o{ raw_contacts : owns
    scraping_jobs ||--o{ raw_contacts : produces
    raw_contacts ||--o{ filtered_contacts : filters_to
    filtered_contacts ||--o{ verified_contacts : verifies_to
    verified_contacts }o--|| contact_batches : batched_into
    client_registry ||--o{ bison_account_sync : syncs_with
    client_registry ||--o{ client_leads : tracks
    client_registry ||--o{ client_targets : configures