atinstantrequiredledgerEntry
conceptWhat one stage confirmed of one message, batch or entity, with the load it was in: a row of the stage ledger, only ever added
Model flow. Written in commons/data/models/flow/mod.ts:120. Identified by ledgerEntryId.
Governance: attributes
entitiesintegeroptionalThe entities a batch carried at this stage
Becomes the column entities of ledger_entry.
Written at commons/data/models/flow/mod.ts:128
graincode of grainrequiredWhat the row stands for
Becomes the column grain of ledger_entry.
Written at commons/data/models/flow/mod.ts:127
ledgerEntryIdidentifierrequiredWhat identifies the row
Becomes the column ledger_entry_id of ledger_entry.
Written at commons/data/models/flow/mod.ts:123
outcomecode of outcomerequiredWhat it confirmed
Becomes the column outcome of ledger_entry.
Written at commons/data/models/flow/mod.ts:126
stagecode of stagerequiredsubjecttextrequiredThe message, batch or entity it is about
Becomes the column subject of ledger_entry.
Written at commons/data/models/flow/mod.ts:124
Governance: relationships
loadoneThe load it was in To load. Written at commons/data/models/flow/mod.ts:120
reasonoptionalWhy, where it did not pass To reason. Written at commons/data/models/flow/mod.ts:120
Logical: the table
Projects to the table ledger_entry with the primary key ledger_entry_id.
| Column | Type | Null | Role | From |
|---|---|---|---|---|
at | timestamp | false | attribute | ledgerEntry.at |
entities | integer | true | attribute | ledgerEntry.entities |
grain | text | false | attribute | ledgerEntry.grain |
ledger_entry_id | text | false | attribute | ledgerEntry.ledgerEntryId |
load_id | text | false | reference | ledgerEntry.load |
outcome | text | false | attribute | ledgerEntry.outcome |
reason_id | text | true | reference | ledgerEntry.reason |
stage | text | false | attribute | ledgerEntry.stage |
subject | text | false | attribute | ledgerEntry.subject |
Physical: SQL
CREATE TABLE IF NOT EXISTS "ledger_entry" (
"ledger_entry_id" VARCHAR NOT NULL PRIMARY KEY,
"subject" VARCHAR NOT NULL,
"stage" VARCHAR NOT NULL,
"outcome" VARCHAR NOT NULL,
"grain" VARCHAR NOT NULL,
"entities" INTEGER,
"at" TIMESTAMPTZ NOT NULL,
"load_id" VARCHAR NOT NULL,
"reason_id" VARCHAR,
CONSTRAINT "ledger_entry_load_id_fk" FOREIGN KEY ("load_id") REFERENCES "load" ("load_id"),
CONSTRAINT "ledger_entry_reason_id_fk" FOREIGN KEY ("reason_id") REFERENCES "reason" ("reason_id"),
CONSTRAINT "ledger_entry_stage_ck" CHECK ("stage" IN ('received', 'captured', 'parsed', 'mapped', 'validated', 'forwarded', 'dest_verdict', 'usable')),
CONSTRAINT "ledger_entry_outcome_ck" CHECK ("outcome" IN ('passed', 'failed', 'rejected', 'accepted', 'unusable')),
CONSTRAINT "ledger_entry_grain_ck" CHECK ("grain" IN ('message', 'batch', 'entity'))
);CREATE TABLE IF NOT EXISTS "ledger_entry" (
"ledger_entry_id" TEXT NOT NULL PRIMARY KEY,
"subject" TEXT NOT NULL,
"stage" TEXT NOT NULL,
"outcome" TEXT NOT NULL,
"grain" TEXT NOT NULL,
"entities" INTEGER,
"at" TIMESTAMPTZ NOT NULL,
"load_id" TEXT NOT NULL,
"reason_id" TEXT,
CONSTRAINT "ledger_entry_load_id_fk" FOREIGN KEY ("load_id") REFERENCES "load" ("load_id"),
CONSTRAINT "ledger_entry_reason_id_fk" FOREIGN KEY ("reason_id") REFERENCES "reason" ("reason_id"),
CONSTRAINT "ledger_entry_stage_ck" CHECK ("stage" IN ('received', 'captured', 'parsed', 'mapped', 'validated', 'forwarded', 'dest_verdict', 'usable')),
CONSTRAINT "ledger_entry_outcome_ck" CHECK ("outcome" IN ('passed', 'failed', 'rejected', 'accepted', 'unusable')),
CONSTRAINT "ledger_entry_grain_ck" CHECK ("grain" IN ('message', 'batch', 'entity'))
);CREATE TABLE IF NOT EXISTS "ledger_entry" (
"ledger_entry_id" TEXT NOT NULL PRIMARY KEY,
"subject" TEXT NOT NULL,
"stage" TEXT NOT NULL,
"outcome" TEXT NOT NULL,
"grain" TEXT NOT NULL,
"entities" INTEGER,
"at" TEXT NOT NULL,
"load_id" TEXT NOT NULL,
"reason_id" TEXT,
CONSTRAINT "ledger_entry_load_id_fk" FOREIGN KEY ("load_id") REFERENCES "load" ("load_id"),
CONSTRAINT "ledger_entry_reason_id_fk" FOREIGN KEY ("reason_id") REFERENCES "reason" ("reason_id"),
CONSTRAINT "ledger_entry_stage_ck" CHECK ("stage" IN ('received', 'captured', 'parsed', 'mapped', 'validated', 'forwarded', 'dest_verdict', 'usable')),
CONSTRAINT "ledger_entry_outcome_ck" CHECK ("outcome" IN ('passed', 'failed', 'rejected', 'accepted', 'unusable')),
CONSTRAINT "ledger_entry_grain_ck" CHECK ("grain" IN ('message', 'batch', 'entity'))
);Physical: the typed table
Read and written from TypeScript with the types the model gives: import { ledgerEntry } from "@intellectual-frontiers/data/sql/typed/models". Generated in commons/data/sql/typed/models/flow.auto.ts: do not edit.
import { from } from "@intellectual-frontiers/data/sql/typed";
import { ledgerEntry } from "@intellectual-frontiers/data/sql/typed/models";
const rows = await from(ledgerEntry).select((s) => ({ ledgerEntryId: s.ledgerEntry.ledgerEntryId, subject: s.ledgerEntry.subject })).run(runner);