<!-- Source: @site/projects/sqlens-for-laravel/docs/rules/cap-l0-tenancy-not-declared.md -->
<!-- Canonical: https://docs.pushery.com/sqlens-for-laravel/rules/cap-l0-tenancy-not-declared/ -->

# CAP.L0.TENANCY_NOT_DECLARED — this project looks multi-tenant and has not said so

> An audit across N tenant databases is not one statement. A report about whichever tenant was default reads exactly like a report about the application.

- **Category:** safety
- **Level:** 0
- **Stability:** stable
- **Suites:** audit

Signals in this project suggest it is multi-tenant, and `sqlens.audit.tenancy.mode` is still `none`.

## The failure this prevents

With several tenant databases, auditing whichever connection happens to be the default produces a
report about **one customer** that is indistinguishable from a report about the application: same
header, same findings, same exit code. A reader draws a conclusion about their system from a
statement about one tenant's database.

There is no safe default here. Every tenant is the wrong one to pick on somebody's behalf, so the run
stops instead of choosing.

## The check is a heuristic, and saying so is a valid answer

The notice names the signals it found, because "this looks multi-tenant" without them is an assertion
you cannot check. The heuristic is allowed to be wrong.

## What to do

Either declare a reference tenant:

```php
// config/sqlens.php
'audit' => [
    'tenancy' => [
        'mode' => 'explicit',
        'reference' => 'tenant_reference',
    ],
],
```

The same two keys answer it when the signals are wrong and the project has one database. `none` is
already the default, and the signals are read on every run that is not `explicit`, so setting `none`
changes nothing. Name the connection the audit reads instead:

```php
'audit' => [
    'tenancy' => [
        'mode' => 'explicit',
        'reference' => 'pgsql_main',
    ],
],
```

The header then says which database the findings describe. What is not an answer is leaving the
question open while the report claims to be about the application.

## Related

- [The audit suite](https://docs.pushery.com/sqlens-for-laravel/audit.md) — which tenant a report is about, and how the header states it
- [Tenancy reference missing](https://docs.pushery.com/sqlens-for-laravel/rules/cap-l0-tenancy-reference-missing.md) — the project answered `explicit` and stopped halfway
