IF Commons GitHub

tenant

concept

A boundary that separates one customer's data from another's, in a hierarchy of boundaries

Model arcaTenancy. Written in commons/data/models/arca-tenancy/tenancy.ts:70. Identified by tenantId.

Governance: attributes

ancestrytextrequired

The path of the tenant's parents from the root, kept by the operation that moves a tenant, so that a subtree is one query

Becomes the column ancestry of tenant.

Written at commons/data/models/arca-tenancy/tenancy.ts:77

createdAtinstantrequired

When the tenant was made

Becomes the column created_at of tenant.

Written at commons/data/models/arca-tenancy/tenancy.ts:82

displayNametextrequired

The name the tenant is shown by

Becomes the column display_name of tenant.

Written at commons/data/models/arca-tenancy/tenancy.ts:76

isolationcode of isolationrequired

How much of the platform the tenant has to itself

Becomes the column isolation of tenant.

Written at commons/data/models/arca-tenancy/tenancy.ts:81

kindcode of tenantKindrequired

What the tenant is in the hierarchy

Becomes the column kind of tenant.

Written at commons/data/models/arca-tenancy/tenancy.ts:74

slugtextrequired

The short name the tenant is addressed by, unique among tenants

Becomes the column slug of tenant.

Written at commons/data/models/arca-tenancy/tenancy.ts:75

statuscode of tenantStatusrequired

Where the tenant is in its life

Becomes the column status of tenant.

Written at commons/data/models/arca-tenancy/tenancy.ts:80

tenantIdidentifierrequired

What identifies the tenant, made by the application when it is created

Becomes the column tenant_id of tenant.

Written at commons/data/models/arca-tenancy/tenancy.ts:73

Governance: relationships

organizationoptional

The organization the tenant is for; a pool of consumers has none To organization. Written at commons/data/models/arca-tenancy/tenancy.ts:86

parentoptional

The tenant this one is under; the root has none To tenant. Written at commons/data/models/arca-tenancy/tenancy.ts:90

Logical: the table

Projects to the table tenant with the primary key tenant_id.

ColumnTypeNullRoleFrom
ancestrytextfalseattributetenant.ancestry
created_attimestampfalseattributetenant.createdAt
display_nametextfalseattributetenant.displayName
isolationtextfalseattributetenant.isolation
kindtextfalseattributetenant.kind
organization_party_idtexttruereferencetenant.organization
parent_tenant_idtexttruereferencetenant.parent
slugtextfalseattributetenant.slug
statustextfalseattributetenant.status
tenant_idtextfalseattributetenant.tenantId

Physical: SQL

CREATE TABLE IF NOT EXISTS "tenant" (
    "tenant_id" VARCHAR NOT NULL PRIMARY KEY,
    "kind" VARCHAR NOT NULL,
    "slug" VARCHAR NOT NULL,
    "display_name" VARCHAR NOT NULL,
    "ancestry" VARCHAR NOT NULL,
    "status" VARCHAR NOT NULL,
    "isolation" VARCHAR NOT NULL,
    "created_at" TIMESTAMPTZ NOT NULL,
    "organization_party_id" VARCHAR,
    "parent_tenant_id" VARCHAR,
    CONSTRAINT "tenant_organization_party_id_fk" FOREIGN KEY ("organization_party_id") REFERENCES "organization" ("party_id"),
    CONSTRAINT "tenant_parent_tenant_id_fk" FOREIGN KEY ("parent_tenant_id") REFERENCES "tenant" ("tenant_id"),
    CONSTRAINT "tenant_slug_uq" UNIQUE ("slug"),
    CONSTRAINT "tenant_kind_ck" CHECK ("kind" IN ('platform', 'reseller', 'business', 'consumer_pool')),
    CONSTRAINT "tenant_status_ck" CHECK ("status" IN ('active', 'suspended', 'closed')),
    CONSTRAINT "tenant_isolation_ck" CHECK ("isolation" IN ('shared', 'dedicated')),
    CONSTRAINT "tenant_tenant_not_its_own_parent_ck" CHECK ("tenant_id" <> "parent_tenant_id")
);

Physical: the typed table

Read and written from TypeScript with the types the model gives: import { tenant } from "@intellectual-frontiers/data/sql/typed/models". Generated in commons/data/sql/typed/models/arca-tenancy.auto.ts: do not edit.

import { from } from "@intellectual-frontiers/data/sql/typed";
import { tenant } from "@intellectual-frontiers/data/sql/typed/models";

const rows = await from(tenant).select((s) => ({ tenantId: s.tenant.tenantId, kind: s.tenant.kind })).run(runner);

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