Skip to content

Commit 2f9543d

Browse files
committed
docs(objectql): the injected organization_id is stamped on insert and NOT NULL on a table the driver creates
"Multi-Tenant Schemas" said the column stays NULL where no organization context exists. Since the driver creates a tenant column NOT NULL, a table it creates refuses that write. Say what main does: the stamp (ADR-0131 D9), the NOT NULL at CREATE TABLE (ADR-0131 D1 and the tenant-column-not-null-ddl changeset), the tables that stay nullable until the ownership ceremony, and the opt-out for organization-less rows. Claude-Session: https://claude.ai/code/session_01Er1tmLgRYyGBSrDcDsUMqQ Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9dc1f42 commit 2f9543d

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

‎content/docs/protocol/objectql/schema.mdx‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -719,9 +719,9 @@ full_name:
719719

720720
Row-level isolation runs on **one platform column**: `organization_id`, a lookup to
721721
`sys_organization`. The registry injects it into every registered object that has not
722-
opted out (`hidden`, `readonly`, `required: false` — it is server-populated on insert
723-
and stays NULL where no organization context exists), so a tenant-scoped object
724-
declares **nothing** about tenancy:
722+
opted out (`hidden`, `readonly`, `required: false` — the platform stamps it on
723+
insert, so the author never writes it), so a tenant-scoped object declares **nothing**
724+
about tenancy:
725725

726726
```yaml
727727
name: customer
@@ -731,6 +731,22 @@ fields:
731731
required: true
732732
```
733733

734+
`required: false` describes the authoring surface, not the stored value: NULL is not an
735+
organization (ADR-0131 D1). An insert is stamped with the writer's organization — under
736+
the `single` posture, with the Default Organization — and a write that names none is
737+
refused wherever an organization can exist (ADR-0131 D9). A table the SQL or Turso
738+
driver creates carries the column `NOT NULL` at `CREATE TABLE`, so the database itself
739+
refuses a row with no organization, an `upsert` included (ADR-0131 D1; changeset
740+
`tenant-column-not-null-ddl` of `@objectstack/driver-sql` and `@objectstack/driver-turso`).
741+
The in-memory driver enforces no `NOT NULL`. A table that already existed — created by an
742+
earlier release, or one the driver adds the column to — keeps a nullable column until
743+
[`os migrate organization-ownership`](/docs/deployment/cli#os-migrate-organization-ownership)
744+
tightens it, and that ceremony cannot tighten a rotated shard or a table on the Turso
745+
remote face; [`os migrate plan`](/docs/deployment/cli#tenant-columns-still-nullable-advisory)
746+
lists every tenant column still nullable, with the reason. An object whose rows belong
747+
to no organization does not leave the column empty — it opts out, and has no column at
748+
all.
749+
734750
The column's existence does not depend on the deployment's tenancy posture — only its
735751
*index* does, since nothing filters by organization on a single-organization stack. An
736752
object opts **out** by declaring `tenancy.enabled: false`

0 commit comments

Comments
 (0)