IF Commons GitHub

membership

concept

A user's place in a tenant

Model identity. Written in commons/data/models/identity/concepts.ts:98. Identified by membershipId.

Governance: attributes

joinedAtinstantoptional

When the user became a member

Becomes the column joined_at of membership.

Written at commons/data/models/identity/concepts.ts:104

membershipIdidentifierrequired

What identifies the membership, made by the application

Becomes the column membership_id of membership.

Written at commons/data/models/identity/concepts.ts:101

removedAtinstantoptional

When the membership ended

Becomes the column removed_at of membership.

Written at commons/data/models/identity/concepts.ts:105

sourcecode of membershipSourcerequired

How the user came to be a member

Becomes the column source of membership.

Written at commons/data/models/identity/concepts.ts:103

statuscode of membershipStatusrequired

Where the membership is

Becomes the column status of membership.

Written at commons/data/models/identity/concepts.ts:102

Governance: relationships

tenantone

The tenant To tenant. Written at commons/data/models/identity/concepts.ts:286

userAccountone

The user To userAccount. Written at commons/data/models/identity/concepts.ts:98

Logical: the table

Projects to the table membership with the primary key membership_id.

ColumnTypeNullRoleFrom
joined_attimestamptrueattributemembership.joinedAt
membership_idtextfalseattributemembership.membershipId
removed_attimestamptrueattributemembership.removedAt
sourcetextfalseattributemembership.source
statustextfalseattributemembership.status
tenant_idtextfalsereferencemembership.tenant
user_account_principal_idtextfalsereferencemembership.userAccount

Physical: SQL

CREATE TABLE IF NOT EXISTS "membership" (
    "membership_id" VARCHAR NOT NULL PRIMARY KEY,
    "status" VARCHAR NOT NULL,
    "source" VARCHAR NOT NULL,
    "joined_at" TIMESTAMPTZ,
    "removed_at" TIMESTAMPTZ,
    "user_account_principal_id" VARCHAR NOT NULL,
    "tenant_id" VARCHAR NOT NULL,
    CONSTRAINT "membership_user_account_principal_id_fk" FOREIGN KEY ("user_account_principal_id") REFERENCES "user_account" ("principal_id"),
    CONSTRAINT "membership_tenant_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "tenant" ("tenant_id"),
    CONSTRAINT "membership_user_account_principal_id_tenant_id_uq" UNIQUE ("user_account_principal_id", "tenant_id"),
    CONSTRAINT "membership_status_ck" CHECK ("status" IN ('invited', 'active', 'suspended', 'removed')),
    CONSTRAINT "membership_source_ck" CHECK ("source" IN ('invited', 'directory', 'domain_capture', 'self_join', 'admin'))
);

Physical: the typed table

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

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

const rows = await from(membership).select((s) => ({ membershipId: s.membership.membershipId, status: s.membership.status })).run(runner);

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