Is Your B2B SaaS Ready for Multiple Companies? A Multi-Tenant Database Architecture Checklist
Is your B2B SaaS ready for multiple companies? This multi-tenant database checklist verifies isolation, RLS, billing, jobs, and deletion before onboarding.
Direct answer: A multi-tenant database architecture checklist verifies that each company using your B2B SaaS sees only its own data, pays only for its own usage, and can be restored, exported or deleted without affecting other companies. Check the isolation model, tenant keys, database enforcement, permissions, billing, jobs, storage, backups and cross-tenant tests before onboarding the second company.
Your first customer forgives a lot. Your second customer compares you to every vendor they have reviewed. A US buyer will ask how you isolate tenants, and "we filter by company ID in code" is not a strong answer. One forgotten filter, one shared cache key, one unscoped background job can expose one company's records to another.
This checklist gives you a reviewable way to answer that buyer. Work through it in order. Score each section honestly. Fix the Fail items before you promise isolation in a contract. Platform behaviour was checked against the PostgreSQL documentation and the AWS SaaS Lens on 30 November 2026.
How to score yourself
Score each section as Pass, Partial, or Fail. Pass means the rule is enforced and tested, not just documented. Partial means it works on the happy path but has an untested edge case. Fail means it depends on a developer remembering to do it.

Sections 1 to 4 and 10 must be Pass. The rest can start as Partial with a dated plan.
Ship only if sections 1 to 4 and 10 are Pass. Sections 5 to 9 can be Partial at first launch if you have a dated plan and a manual workaround, but do not promise them in a contract until they are Pass. Keep the scored sheet with the release notes. A buyer who sees a dated Fail with a fix plan trusts you more than a vendor who claims everything is Pass with no evidence.
1. Choose the isolation model
A tenant is one customer organisation using your product. The isolation model decides how tenants share a database. AWS describes this as a spectrum: pool, where tenants share resources; silo, where each tenant gets dedicated resources; and bridge, a mix of the two.

Pool is the usual default. Bridge or silo is a contract decision, not a taste decision.
| Model | How it works | Best for | Main cost |
|---|---|---|---|
| Shared database, shared schema (pool) | One set of tables, tenant_id on every tenant-owned row | Many small to mid-size B2B customers, self-serve signup | One query bug can leak data if enforcement is code-only |
| Shared database, schema per tenant (bridge) | Each tenant gets its own schema in one database | Mid-size customers who ask about separation in sales calls | Migrations run per schema, catalog grows, cross-tenant reporting gets awkward |
| Database per tenant (silo) | Each tenant gets its own database | Few large, regulated or data-residency customers | Provisioning, migrations, connection pools and per-tenant cost multiply |
For most US B2B SaaS products with 5 to 50 employees on the vendor side, start with pool. Keep the door open to bridge or silo for one large customer. The trick is to keep tenant_id on every table even in a dedicated database. Then a tenant can move from pooled to dedicated storage by changing routing, not by rewriting queries.
Decide and write down: which model is default, what triggers a move to dedicated storage, who pays for the extra operations work, and how a tenant moves back. If you cannot write that in one paragraph, you have not decided yet.
2. Put tenant_id everywhere, with composite keys
Every tenant-owned table gets a tenant_id column, NOT NULL, with a foreign key to the tenants table. That includes child tables, join tables, comments, attachment metadata, audit rows and billing rows. Global tables, such as a public pricing page or a country list, are the only exception, and they should be listed explicitly.
Two details do quiet work. First, use UUID primary keys, not sequential integers, for anything exposed in a URL. Sequential IDs make it trivial to guess another tenant's record IDs. UUIDs do not replace authorisation checks, but they make a missing check harder to find by guessing.
Second, use composite keys and composite foreign keys that include tenant_id. A booking should reference a customer with (tenant_id, customer_id), not with customer_id alone. Then the database itself refuses a booking that points at another tenant's customer, even if application code passes the wrong ID. Uniqueness should also be scoped per tenant. Two companies can each have a customer with the same email address. A global unique constraint on email will block the second signup and create a support ticket that reveals the first customer exists.
Checklist for this section:
- To do:
tenant_idisNOT NULLon every tenant-owned table - To do: Indexes lead with
tenant_id, because almost every query filters on it - To do: Foreign keys include
tenant_id - To do: Unique constraints are scoped to
(tenant_id, ...) - To do: Primary keys exposed in URLs are UUIDs, not sequential integers
3. Enforce isolation in the database with RLS
Application filters are one layer, not a guarantee. PostgreSQL row-level security, or RLS, moves the tenant filter into the database. PostgreSQL evaluates the policy before returning any row, so a query that forgets the tenant filter returns nothing instead of everything.

Isolation has to hold at every layer, not only in the query you remembered to filter.
The pattern for a shared schema is small:
ALTER TABLE projects ENABLE ROW LEVEL SECURITY;
ALTER TABLE projects FORCE ROW LEVEL SECURITY;
CREATE POLICY tenant_isolation ON projects
USING (tenant_id = current_setting('app.tenant_id', true)::uuid)
WITH CHECK (tenant_id = current_setting('app.tenant_id', true)::uuid);Four details catch teams out. First, use FORCE ROW LEVEL SECURITY so the table owner also obeys the policy. PostgreSQL bypasses RLS for superusers and roles with BYPASSRLS in every case, and table owners bypass it by default unless you force it. Run the application as a dedicated non-superuser, non-owner role with no BYPASSRLS privilege.
Second, set the tenant per transaction, not per session. Use SET LOCAL or set_config('app.tenant_id', $1, true) with the third argument true, which scopes the value to the transaction. With connection pooling, a session-level setting can leak into the next request on the same connection.
Third, write both USING and WITH CHECK. USING controls which rows you can read, update or delete. WITH CHECK controls which rows you can insert or update into. Without WITH CHECK, a user could reassign a row to another tenant by changing tenant_id.
Fourth, enable RLS on every tenant table. PostgreSQL uses a default-deny policy when RLS is enabled and no policy exists, which is the fail-closed behaviour you want. A missing policy should break a feature in staging, not leak data in production.
If you use Supabase, the same principle applies with auth.uid() and membership checks. The guide to fixing Supabase RLS in Lovable apps shows the diagnostic order: audit, backfill owner columns, add policies per operation, then verify with two users. The multi-tenant version adds one step: replace the single-owner check with a membership check, so a user sees a row only if they belong to that tenant.
4. Separate identity, membership and permissions
Authentication answers who the user is. Authorisation answers what that user can do for a specific tenant. Model them as separate concepts from day one.
You need four records: a global user, a tenant or organisation, a membership linking a user to a tenant, and a role or permission set attached to that membership. A person can then own one workspace and be a viewer in another, without a second account. Switching workspaces changes which membership the server reads, not which user is signed in.
Check permissions on the server, on every write, at the service boundary. Hiding a button is not access control. Background jobs, API endpoints, webhooks, internal tools and command-line utilities must enforce the same rules as the web app. A support script that bypasses permissions is a backdoor, even if only your team knows about it.
Keep permissions granular. A user may be able to view invoices but not change payment methods, or export data but not delete it. Store permissions as data, not as if role == "admin" branches scattered through code. A hierarchy check also helps: a member should not be able to remove or demote someone ranked above them. Enforce that in the database or service layer, not only in the UI.
5. Model billing as entitlements, make webhooks idempotent
A plan is what sales sells, with a name and a price. Seats are how many people can log in. Entitlements are which features or modules a tenant can use, and with what limits. Code should ask "can this tenant use this feature?", never "is this the Pro plan?".
Keep your own record of entitlements. Do not use your payment provider as the only source of truth. Payment webhooks are asynchronous and can arrive late, out of order, or more than once. Log the event ID, verify the signature, and make the handler idempotent so a retry does not create duplicate rows or overwrite newer state with older state. Then run a scheduled reconcile job that fetches current subscription state and corrects drift before a customer emails you about it.
Decide the lifecycle rules in writing. Does a downgrade take effect immediately or at renewal? Can an account exceed a new limit temporarily? Are existing records retained when a feature is removed? What happens on failed payment, trial end, pause and cancellation? These are product decisions with database consequences. If you have not decided them, your webhook handler will decide them by accident.
The Lovable Stripe webhook fix shows the same three-layer diagnostic: delivery, signature and function access, then the exact row the pricing gate reads. Use that order when a customer reports "paid but still free."
6. Make jobs tenant-aware and fair
Every background job must carry its tenant ID. A job without a tenant is a bug, not a system task. The worker should set tenant context before touching data, validate that the tenant still exists, and confirm the operation is still allowed before making changes. A cancellation that arrives while an export job is queued should stop the export, not deliver it anyway.
Make retries safe. A job that sends an email, creates an invoice or generates an export should not duplicate side effects because a worker restarted. Use a stable idempotency key per job and per external side effect. Record the tenant ID, actor or trigger type, correlation ID and retry count in the job envelope, so you can answer which tenant was affected, what failed, and whether the issue is isolated or systemic.
Protect against noisy neighbours. One tenant importing a million rows should not delay everyone else's reminder emails. Use per-tenant rate limits, concurrency limits, priority classes or a separate queue for heavy work. Add per-tenant query timeouts and usage metering, so one heavy report does not consume the shared pool.
7. Scope storage, cache, search and logs per tenant
Isolation is a system property, not a database property. Trace tenant context through every subsystem.
Object storage: use predictable tenant-scoped key prefixes, such as tenants/{tenant_id}/uploads/{file_id}. Never trust a client-provided path as an authorisation decision. Grant access through a server-generated, time-limited URL or a controlled download endpoint. Define retention, deletion and export behaviour for files, thumbnails and derived copies.
Cache: include tenant identity in every cache key unless the value is intentionally global. Be careful with permission checks, feature flags, dashboard summaries and server-rendered responses. A cache that ignores tenant context can serve valid data to the wrong customer. The same rule applies to CDN keys and edge caches.
Search and analytics: a search index needs the same tenant filter as the database. A missing filter in vector search leaks text rather than a row. Analytics pipelines should carry tenant_id from ingestion, not add it later by joining on a guessed key. If you cannot filter an analytics table by tenant, do not put tenant data in it.
Logs and metrics: include tenant ID, request ID and job ID in structured logs. Do not log sensitive payloads because they are convenient during debugging. Metrics should distinguish platform-wide failures from tenant-specific problems. High-cardinality tenant labels can become expensive, so store detailed tenant-level information in logs or traces, not in every metric label.
8. Plan migrations, backups, single-tenant restore and deletion
Migrations are easy to test on a clean development database and hard to run across tenants with different data volumes and legacy states. Prefer backward-compatible changes that let old and new application versions coexist during deployment. Add a nullable column before writing to it, backfill in controlled batches, then enforce the constraint after the data is ready. Avoid long transactions that lock large tenant tables during peak usage. For schema-per-tenant or database-per-tenant designs, maintain an explicit inventory of tenant versions and migration status. A migration system should tell you which tenants succeeded, which failed, and whether a retry is safe.
Backups need a tenant-aware restore path. A full-database snapshot covers everyone, but restoring it rolls back everyone. Rehearse the harder case: restore one tenant without affecting others. The usual pattern is to restore the snapshot to an isolated instance, extract only that tenant's rows, verify counts and checksums, then import them back. For schema-per-tenant designs, a schema-level dump is simpler. For database-per-tenant designs, a per-tenant snapshot is simplest. Choose the model with this rehearsal in mind, not just with signup in mind.
Deletion is a distributed transaction across the primary database, object storage, search index, cache, analytics warehouse and backups. A single DELETE statement is not enough. For each store, decide: what holds tenant data, what deletes it, what proves it, and what happens on restore. Backups that restore deleted rows reintroduce personal data. Your policy should state that deleted data is not restored, or that restores use a filtered extraction that excludes deleted tenants.
For teams scoping a first release, the MVP development approach starts with the one journey early users must complete, then adds the account separation, permissions and billing that journey needs. Multi-tenancy is part of that first-release scope when the product will serve more than one company, not a later retrofit.
9. Build support access, exports and audit trails
Internal tools often become the most privileged surface in a SaaS product. Build them as part of the architecture, not as ad hoc database scripts. Support tooling should provide tenant lookup, read-only diagnostics by default, explicit confirmation for mutations, role-based access for support staff, audit logs for every sensitive action, impersonation indicators in the interface, and a way to link actions to a ticket or internal reason.
Prefer service APIs over direct production database access. If direct access is unavoidable, use separate credentials, strong controls and monitoring. The objective is not to slow support down. It is to make powerful actions understandable, attributable and reversible where possible.
Treat exports as a first-class capability. An export should define its scope, format, consistency model, access controls, expiry and audit behaviour. Record who requested it, for which tenant, when it was created, and when it expires. Protect the resulting file like any other tenant data. If the export is generated asynchronously, do not silently include data from another tenant through shared references or global tables.
For larger organisations with departments, business units and approval authority, enterprise software development work scopes process variation, separation of duties and record visibility before choosing an application structure. The same discipline applies to a small B2B SaaS product: policy becomes explicit application behaviour, not informal convention.
10. Prove it with cross-tenant tests
Write tests that act like an attacker who already has a valid login. OWASP ranks Broken Object Level Authorisation first in its 2023 API Security Top 10: the user can reach the endpoint legitimately but swaps in an object ID that is not theirs. Its advice is to test authorisation checks and not deploy when they fail.

Two test tenants and a dated result are stronger than a promise in a sales call.
Buyer verification script, run in staging with two test tenants:
- Create Tenant A and Tenant B, each with a user at every role.
- Log in as Tenant A and request Tenant B's objects by ID on every endpoint: list, detail, update, delete.
- Try to create an object in Tenant B by putting B's ID in the request body.
- Try to read Tenant B's files, exports and search results with Tenant A's session.
- Run Tenant A's background jobs and confirm nothing of Tenant B's changes.
- Run the suite in CI on every pull request.
Expect 404, not 403, for cross-tenant object requests where you do not want to confirm existence. Expect an empty list, not an error, where RLS correctly filters. A UI that hides rows is not proof. An API that returns no rows is proof.
Illustrative example: Northwind Forms is an illustrative B2B SaaS product, not a verified client case. It lets two companies collect intake forms. The team starts with a shared schema, adds tenant_id to forms, submissions, files and audit rows, and adds composite foreign keys. They enable RLS with FORCE, set tenant context per transaction, and run the verification script above. Tenant A's test user requests Tenant B's submission ID and receives 404. Tenant A's export contains only Tenant A's forms. A restore rehearsal extracts only Tenant A's rows from a snapshot. The team then writes the result into a one-page isolation note they can share with buyers, with the test date and the exact suite that ran.
A note on evidence
No first-hand JUHENZA multi-tenant build is claimed here, and no client result is invented. The tenancy terms come from the AWS SaaS Lens. The RLS behaviour, including FORCE, BYPASSRLS and default deny, comes from the PostgreSQL documentation. The authorisation test pattern comes from OWASP. Northwind Forms is an illustrative product with invented numbers and outcomes.
If you want proof for a specific product, ask for five artifacts: the isolation model decision, the schema and foreign keys, the RLS policies with the application role, the dated cross-tenant test run, and the restore rehearsal note. A checklist that nobody has run is a plan, not evidence.
What about erasure duties under GDPR, CCPA or another regime? This guide does not give legal advice. Your deletion policy needs a decision on backups, and that decision should be confirmed with a qualified professional for the jurisdictions you serve.
Common mistakes, limitations and when to involve a specialist
Common mistakes:
- Relying on
WHERE tenant_id = ...in application code with no database enforcement - Connecting as the table owner or superuser, which bypasses RLS
- Setting tenant context per session instead of per transaction, so a pooled connection leaks context
- Forgetting
WITH CHECK, so a user can reassign a row to another tenant - Using sequential IDs in URLs and trusting them as security
- Caching permission checks or dashboard summaries without tenant in the key
- Treating webhooks as ordered and exactly-once, then double-billing on retry
- Assuming backups equal deletion, then restoring deleted data
- Giving support staff standing admin access with no audit trail
- Shipping a single-tenant schema "for now" to launch a week sooner. The retrofit touches every query written since.
Limitations: this checklist covers the common B2B SaaS shape: one application, one primary database, many small to mid-size tenants, with an optional dedicated database for one large customer. It does not cover data residency in multiple regions, regulated health or financial data, or a multi-region active-active design.
When to involve a specialist: bring one in if a buyer contract requires physical isolation, a specific region, a specific encryption model or a formal audit. Also involve one if you need to migrate a live single-tenant product with years of data; scope the migration as its own project with a backfill plan, a rollback or forward-repair plan, and a maintenance window or replication plan.
Where this fits and what to do next
This post sits in Startups and SaaS, under SaaS product foundations. For the single-owner RLS diagnostic, read the Supabase RLS guide. For the billing layer, read the Stripe webhook fix. For the build itself, see custom software development for SaaS products and business platforms, and the startups and SaaS page for the wider context.
Your second customer is the real architecture test. Choose the isolation model deliberately, put tenant_id everywhere with composite keys, enforce isolation in the database, separate identity from membership, model billing as entitlements, make jobs tenant-aware, scope storage and cache per tenant, rehearse restore and deletion, and prove it with cross-tenant tests.
If you want a review of your current schema before you onboard the next company, discuss your SaaS project and share your brief. We will scope a review with deliverables, exclusions and acceptance checks agreed before work starts.