Search docs

Docs search
Back to Rule Catalog
AP-DB-001Database

Tenant discriminator column exists for same-schema model

Checks that same-schema multi-tenant tables include tenant discriminator evidence.

errorviolationNo auto-fix

How to fix

  1. Add the tenant discriminator column where required.
  2. Update schema artifacts and migrations.
  3. If the system uses a different tenant isolation model, update the architecture configuration and ADRs.

What the rule validates

A same-schema tenant model is configured, but ArchPilot could not confirm tenant discriminator coverage.

Why it matters

Tenant discriminators are the foundation for keeping tenant data isolated in shared tables.

Common causes

  • A table is missing tenantId or equivalent.
  • Schema metadata is stale.
  • The tenant model setting does not match the database design.

Typical violation example

An orders table is shared across tenants but has no tenant_id column.

Typical compliant example

Shared tenant tables include tenant_id and application queries filter by it.

Related rules

Adjacent categories

Related files/config

  • db/sql
  • packages/db/prisma/schema.prisma
  • .archpilot/architecture.json

Related CLI commands

  • archpilot validate
  • archpilot validate --ci
AP-DB-001 - Tenant discriminator column exists for same-schema model | ArchPilot Docs