1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-06-20 22:54:05 +00:00
tenancy/src
lukinovec ad4c924d5c
[MINOR BC] Create pending tenants with pending_since, improve --with-pending (#1458)
> Minor breaking change: Pending tenants would previously go through the
creation pipeline as *not* pending and would only be marked as pending
after full creation. Now, pending tenants go through the creation
process with pending_since set from the start.

Pending tenants aren't getting their `pending_since` set until they're
created completely (e.g. their DB was created, migrated and seeded --
first, the tenant is created fully, and only after that, the tenant is
updated to have `pending_since`). This is a problem if someone wants to
e.g. add a job to the `DatabaseCreated` job pipeline that would check
`$this->tenant->pending()`. Since at the point of `DatabaseCreated`, the
tenant's `pending_since` isn't set yet, `$this->tenant->pending()`
returns `false`, even for tenants created using `createPending()`. So
instead of letting the pending tenant get fully created, and only after
that, setting its `pending_since` (using `update()`), we now set
`pending_since` in `create()`. `CreatingPendingTenant` is now dispatched
from the `static::creating` hook, and `PendingTenantCreated` is
dispatched from `static::created` for consistency.

Setting `pending_since` right in `create()` made the `MigrateDatabase`
and `SeedDatabase` jobs exclude the pending tenants during their
creation if the `tenancy.pending.include_in_queries` config was set to
`false` -- in that case, these jobs would never migrate or seed the
databases of pending tenants. So these jobs now pass `--with-pending` to
their underlying commands, with the value set in their `$includePending`
static property (`true` by default). This overrides the
`tenancy.pending.include_in_queries` config -- unless the
`$includePending` properties are set to `false`, these jobs will always
include pending tenants.

The `--with-pending` tenant command option originally worked just to
opt-in for including pending tenants in the command. Now,
`--with-pending` can accept values (`true`/`1` or `false`/`0`), so e.g.
- `tenants:run foo` with
`--with-pending`/`--with-pending=true`/`--with-pending=1` includes
pending tenants
- `tenants:run foo` with `--with-pending=false`/`--with-pending=0`
**excludes** pending tenants (also `--with-pending=foobar` -- invalid
input, considered `false`)

Passing `--with-pending` makes the command bypass the
`tenancy.pending.include_in_queries` config (so e.g. if
`tenancy.pending.include_in_queries` is set to `true`, and
`--with-pending=false` is passed to a command, the command will exclude
pending tenants). When `--with-pending` is not passed, the command will
include or exclude pending tenants based on the
`tenancy.pending.include_in_queries` config.

---------

Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
2026-06-05 15:36:57 -07:00
..
Actions Cloning: improve type annotations, add cloneRoutes() for convenience 2025-11-10 02:16:57 +01:00
Bootstrappers Prevent mkdir() race conditions in FilesystemTenancyBootstrapper (#1453) 2026-04-13 23:57:59 +02:00
Commands phpstan: change InputOption syntax 2026-03-09 02:13:37 +01:00
Concerns [MINOR BC] Create pending tenants with pending_since, improve --with-pending (#1458) 2026-06-05 15:36:57 -07:00
Contracts Features refactor 2025-08-31 23:18:44 +02:00
Controllers [4.x] General code cleanup (#1278) 2024-12-31 00:35:46 +01:00
Database [MINOR BC] Create pending tenants with pending_since, improve --with-pending (#1458) 2026-06-05 15:36:57 -07:00
Enums Make RouteMode enum backed (#1362) 2025-06-02 20:34:49 +02:00
Events Pending tenants refactor (BC break) 2025-08-25 00:01:02 +02:00
Exceptions remove ignition dependencies 2025-06-18 23:29:24 +02:00
Facades [4.x] Support database cache store tenancy (#1290) (resolve #852) 2025-08-08 00:54:01 +02:00
Features [MINOR BC] UserImpersonation: store auth guard in session, add $logout param to stopImpersonating() (#1437) 2026-06-05 14:15:19 -07:00
Jobs [MINOR BC] Create pending tenants with pending_since, improve --with-pending (#1458) 2026-06-05 15:36:57 -07:00
Listeners Change tenant storage listeners into jobs (#1446) 2026-04-22 16:45:54 +02:00
Middleware Remove redundant universal route check from PreventAccess MW (#1427) 2026-05-12 23:59:21 +02:00
Overrides [4.x] Make URL::temporarySignedRoute() respect the bypass parameter (#1438) 2026-03-09 02:07:02 +01:00
Resolvers Correct DomainTenantResolver::isSubdomain() check (#1425) 2026-05-11 14:26:06 +02:00
ResourceSyncing [4.x] Add more relation type annotations (#1424) 2025-12-28 23:20:05 +01:00
RLS [4.x] TableRLSManager refactor, comment constraints (#1354) 2025-07-03 21:12:04 +02:00
UniqueIdentifierGenerators Add UUIDv7Generator 2025-11-04 15:45:48 +01:00
helpers.php resolve minor todos 2025-08-18 15:05:17 +02:00
Tenancy.php [4.x] Add Tenancy::reinitialize() method (#1449) 2026-04-08 19:21:43 +02:00
TenancyServiceProvider.php globalUrl: useAssetOrigin() instead of setAssetRoot() 2025-11-14 10:59:31 +01:00