field_values
append-only facts
What you'll learn
You're writing SQL that reads field_values and need its columns, what each holds, and the DDL as the spec states it.
- every column and its type
- what the object holds and who writes it
- the DDL as the spec states it
A table. append-only facts: (identity_id, field, value JSON, source, confidence, run_id, created_at)
Columns
| Column | Type | Constraints |
|---|---|---|
id | TEXT | PRIMARY KEY |
identity_id | TEXT | NOT NULL REFERENCES identities(id) |
field | TEXT | NOT NULL |
value | TEXT | NOT NULL |
source | TEXT | NOT NULL |
confidence | REAL | NOT NULL DEFAULT 1.0 |
run_id | TEXT | |
referent | TEXT | |
created_at | TEXT | NOT NULL |
Definition
From spec/ledger.sql, which is the machine-checkable form of SPEC.md §3:
CREATE TABLE field_values (
id TEXT PRIMARY KEY, -- ULID
identity_id TEXT NOT NULL REFERENCES identities(id),
field TEXT NOT NULL, -- e.g. 'email', 'linkedin_url'
value TEXT NOT NULL, -- JSON-encoded value
source TEXT NOT NULL, -- adapter id, e.g. 'harvest/profile@1'
confidence REAL NOT NULL DEFAULT 1.0, -- 0.0–1.0
run_id TEXT, -- provenance; nullable for imports
referent TEXT, -- was-about: field_values.id of the value a review or edit concerned (ADR-048); null unless the step declared of:
created_at TEXT NOT NULL
);
CREATE INDEX ix_fv_lookup ON field_values(identity_id, field, created_at DESC);