IF Commons GitHub

ledgerEntry

concept

What 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

atinstantrequired

When

Becomes the column at of ledger_entry.

Written at commons/data/models/flow/mod.ts:129

entitiesintegeroptional

The 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 grainrequired

What the row stands for

Becomes the column grain of ledger_entry.

Written at commons/data/models/flow/mod.ts:127

ledgerEntryIdidentifierrequired

What identifies the row

Becomes the column ledger_entry_id of ledger_entry.

Written at commons/data/models/flow/mod.ts:123

outcomecode of outcomerequired

What it confirmed

Becomes the column outcome of ledger_entry.

Written at commons/data/models/flow/mod.ts:126

stagecode of stagerequired

The stage

Becomes the column stage of ledger_entry.

Written at commons/data/models/flow/mod.ts:125

subjecttextrequired

The 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

loadone

The load it was in To load. Written at commons/data/models/flow/mod.ts:120

reasonoptional

Why, 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.

ColumnTypeNullRoleFrom
attimestampfalseattributeledgerEntry.at
entitiesintegertrueattributeledgerEntry.entities
graintextfalseattributeledgerEntry.grain
ledger_entry_idtextfalseattributeledgerEntry.ledgerEntryId
load_idtextfalsereferenceledgerEntry.load
outcometextfalseattributeledgerEntry.outcome
reason_idtexttruereferenceledgerEntry.reason
stagetextfalseattributeledgerEntry.stage
subjecttextfalseattributeledgerEntry.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'))
);

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);

Titles, headings, exports, tables, columns and requirements. Esc closes.