Data model
Every table, column, default, foreign key and check constraint below is read from the Drizzle schema. Check constraints encode methodology doctrine.
config_files
Section titled “config_files”Export: configFiles.
| Column | Type | Constraints |
|---|---|---|
id |
PgUUID | primary, not null, default gen_random_uuid() |
path |
PgText | not null |
version |
PgInteger | not null |
content |
PgText | not null |
note |
PgText | — |
is_current |
PgBoolean | not null, default false |
kb_document_id |
PgText | — |
created_at |
PgTimestamp | not null, default now() |
Export: flags.
| Column | Type | Constraints |
|---|---|---|
id |
PgUUID | primary, not null, default gen_random_uuid() |
opportunity_id |
PgUUID | not null |
kind |
PgText | not null |
code |
PgText | not null |
severity |
PgText | not null |
reason |
PgText | not null |
rule_ref |
PgText | — |
raised_at |
PgTimestamp | not null, default now() |
expires_at |
PgTimestamp | — |
cleared_at |
PgTimestamp | — |
Foreign keys:
opportunity_id→opportunities.id
Check constraints (verbatim):
-
flags_kind_check:kind in ('rule','judgement') -
flags_severity_check:severity in ('low','medium','high')
mock_crm_writes
Section titled “mock_crm_writes”Export: mockCrmWrites.
| Column | Type | Constraints |
|---|---|---|
id |
PgUUID | primary, not null, default gen_random_uuid() |
opportunity_id |
PgUUID | — |
field |
PgText | not null |
old_value |
PgText | — |
new_value |
PgText | — |
payload |
PgJsonb | not null, default ‘{}’::jsonb |
pushed_at |
PgTimestamp | not null, default now() |
Foreign keys:
opportunity_id→opportunities.id
opportunities
Section titled “opportunities”Export: opportunities.
| Column | Type | Constraints |
|---|---|---|
id |
PgUUID | primary, not null, default gen_random_uuid() |
crm_id |
PgText | not null, unique |
name |
PgText | not null |
account_name |
PgText | not null |
owner_id |
PgUUID | not null |
step |
PgInteger | not null |
p1 |
PgInteger | generated always as (case when step in (1,2) then 30 when step in (3,4) then 60 when step in (5,6) then 90 else null end) |
p2 |
PgInteger | not null |
amount |
PgNumeric | not null |
currency |
PgText | not null, default GBP |
close_date |
PgDateString | not null |
original_close_date |
PgDateString | not null |
outcome |
PgText | — |
product_line |
PgText | — |
competitor |
PgText | — |
meddic_metrics |
PgText | — |
meddic_economic_buyer |
PgText | — |
meddic_decision_criteria |
PgText | — |
meddic_decision_process |
PgText | — |
meddic_identify_pain |
PgText | — |
meddic_champion |
PgText | — |
meddic_unknown |
PgArray | not null, default ‘{}’ |
notes |
PgText | — |
last_activity_at |
PgTimestamp | — |
last_step_change_at |
PgTimestamp | — |
last_p2_change_at |
PgTimestamp | — |
created_at |
PgTimestamp | not null, default now() |
updated_at |
PgTimestamp | not null, default now() |
Foreign keys:
owner_id→users.id
Check constraints (verbatim):
-
opportunities_step_check:step between 1 and 7 -
opportunities_p2_check:p2 in (30,60,90) -
opportunities_outcome_check:outcome is null or … in ('won','lost')
proposed_changes
Section titled “proposed_changes”Export: proposedChanges.
| Column | Type | Constraints |
|---|---|---|
id |
PgUUID | primary, not null, default gen_random_uuid() |
opportunity_id |
PgUUID | not null |
session_id |
PgUUID | — |
field |
PgText | not null |
old_value |
PgText | — |
proposed_value |
PgText | not null |
adjusted_value |
PgText | — |
agent_reasoning |
PgText | not null |
rep_response |
PgText | — |
rep_responded_at |
PgTimestamp | — |
sponsor_verdict |
PgText | — |
sponsor_note |
PgText | — |
sponsor_verdict_at |
PgTimestamp | — |
applied_at |
PgTimestamp | — |
created_at |
PgTimestamp | not null, default now() |
Foreign keys:
-
opportunity_id→opportunities.id -
session_id→sessions.id
Check constraints (verbatim):
-
proposed_changes_rep_response_check:rep_response is null or … in ('approved','adjusted','rejected') -
proposed_changes_sponsor_verdict_check:sponsor_verdict is null or … in ('right','wrong')
regression_runs
Section titled “regression_runs”Export: regressionRuns.
| Column | Type | Constraints |
|---|---|---|
id |
PgUUID | primary, not null, default gen_random_uuid() |
config_snapshot |
PgJsonb | not null |
results |
PgJsonb | not null |
started_at |
PgTimestamp | not null, default now() |
finished_at |
PgTimestamp | — |
is_known_good |
PgBoolean | not null, default false |
sessions
Section titled “sessions”Export: sessions.
| Column | Type | Constraints |
|---|---|---|
id |
PgUUID | primary, not null, default gen_random_uuid() |
opportunity_id |
PgUUID | not null |
flow |
PgText | not null |
mode |
PgText | not null |
elevenlabs_conversation_id |
PgText | — |
started_at |
PgTimestamp | not null, default now() |
ended_at |
PgTimestamp | — |
duration_seconds |
PgInteger | — |
transcript |
PgJsonb | — |
tool_calls |
PgJsonb | — |
outcomes_met |
PgJsonb | — |
outcomes_open |
PgJsonb | — |
session_evidence |
PgJsonb | not null, default ‘{}’::jsonb |
session_outcomes |
PgJsonb | not null, default ‘{}’::jsonb |
summary |
PgText | — |
eval_scores |
PgJsonb | — |
ended_reason |
PgText | — |
step_at_start |
PgInteger | — |
p1_at_start |
PgInteger | — |
p2_at_start |
PgInteger | — |
Foreign keys:
opportunity_id→opportunities.id
Check constraints (verbatim):
-
sessions_mode_check:mode in ('voice','simulation') -
sessions_ended_reason_check:ended_reason is null or … in ('complete','time_budget','rep_ended','error')
stage_history
Section titled “stage_history”Export: stageHistory.
| Column | Type | Constraints |
|---|---|---|
id |
PgUUID | primary, not null, default gen_random_uuid() |
opportunity_id |
PgUUID | not null |
field |
PgText | not null |
old_value |
PgText | — |
new_value |
PgText | — |
step_at_change |
PgInteger | — |
p1_at_change |
PgInteger | — |
p2_at_change |
PgInteger | — |
source |
PgText | not null |
session_id |
PgUUID | — |
changed_at |
PgTimestamp | not null, default now() |
Foreign keys:
-
opportunity_id→opportunities.id -
session_id→sessions.id
Check constraints (verbatim):
stage_history_source_check:source in ('import','session','manual','admin')
Export: users.
| Column | Type | Constraints |
|---|---|---|
id |
PgUUID | primary, not null, default gen_random_uuid() |
name |
PgText | not null |
role |
PgText | not null |
created_at |
PgTimestamp | not null, default now() |
Check constraints (verbatim):
users_role_check:role in ('rep','manager','operator')