closedAtinstantoptionalWhen it was closed
Becomes the column closed_at of period.
Written at commons/data/models/contract/mod.ts:97
A span of time of one scope (a month of a ledger, a reporting quarter) that takes changes while it is open and is closed when its figures are final
Model contract. Written in commons/data/models/contract/mod.ts:88. Identified by periodId.
closedAtinstantoptionalWhen it was closed
Becomes the column closed_at of period.
Written at commons/data/models/contract/mod.ts:97
closedBytextoptionalWho closed it
Becomes the column closed_by of period.
Written at commons/data/models/contract/mod.ts:96
endsOninstantrequiredWhere it ends, not included
Becomes the column ends_on of period.
Written at commons/data/models/contract/mod.ts:94
periodIdidentifierrequiredWhat identifies the period: its scope and span
Becomes the column period_id of period.
Written at commons/data/models/contract/mod.ts:91
reasontextoptionalWhy it was opened again, where it was
Becomes the column reason of period.
Written at commons/data/models/contract/mod.ts:98
scopetextrequiredWhat it is a period of
Becomes the column scope of period.
Written at commons/data/models/contract/mod.ts:92
startsOninstantrequiredWhere it starts
Becomes the column starts_on of period.
Written at commons/data/models/contract/mod.ts:93
statuscode of periodStatusrequiredWhether it takes changes
Becomes the column status of period.
Written at commons/data/models/contract/mod.ts:95
Projects to the table period with the primary key period_id.
| Column | Type | Null | Role | From |
|---|---|---|---|---|
closed_at | timestamp | true | attribute | period.closedAt |
closed_by | text | true | attribute | period.closedBy |
ends_on | timestamp | false | attribute | period.endsOn |
period_id | text | false | attribute | period.periodId |
reason | text | true | attribute | period.reason |
scope | text | false | attribute | period.scope |
starts_on | timestamp | false | attribute | period.startsOn |
status | text | false | attribute | period.status |
CREATE TABLE IF NOT EXISTS "period" (
"period_id" VARCHAR NOT NULL PRIMARY KEY,
"scope" VARCHAR NOT NULL,
"starts_on" TIMESTAMPTZ NOT NULL,
"ends_on" TIMESTAMPTZ NOT NULL,
"status" VARCHAR NOT NULL,
"closed_by" VARCHAR,
"closed_at" TIMESTAMPTZ,
"reason" VARCHAR,
CONSTRAINT "period_scope_starts_on_uq" UNIQUE ("scope", "starts_on"),
CONSTRAINT "period_status_ck" CHECK ("status" IN ('open', 'closed', 'reopened'))
);CREATE TABLE IF NOT EXISTS "period" (
"period_id" TEXT NOT NULL PRIMARY KEY,
"scope" TEXT NOT NULL,
"starts_on" TIMESTAMPTZ NOT NULL,
"ends_on" TIMESTAMPTZ NOT NULL,
"status" TEXT NOT NULL,
"closed_by" TEXT,
"closed_at" TIMESTAMPTZ,
"reason" TEXT,
CONSTRAINT "period_scope_starts_on_uq" UNIQUE ("scope", "starts_on"),
CONSTRAINT "period_status_ck" CHECK ("status" IN ('open', 'closed', 'reopened'))
);CREATE TABLE IF NOT EXISTS "period" (
"period_id" TEXT NOT NULL PRIMARY KEY,
"scope" TEXT NOT NULL,
"starts_on" TEXT NOT NULL,
"ends_on" TEXT NOT NULL,
"status" TEXT NOT NULL,
"closed_by" TEXT,
"closed_at" TEXT,
"reason" TEXT,
CONSTRAINT "period_scope_starts_on_uq" UNIQUE ("scope", "starts_on"),
CONSTRAINT "period_status_ck" CHECK ("status" IN ('open', 'closed', 'reopened'))
);Read and written from TypeScript with the types the model gives: import { period } from "@intellectual-frontiers/data/sql/typed/models". Generated in commons/data/sql/typed/models/contract.auto.ts: do not edit.
import { from } from "@intellectual-frontiers/data/sql/typed";
import { period } from "@intellectual-frontiers/data/sql/typed/models";
const rows = await from(period).select((s) => ({ periodId: s.period.periodId, scope: s.period.scope })).run(runner);