Full v4 changelog
Version 4 brings many new features, with the most important ones being:
- PostgreSQL RLS
- Jetstream/Fortify support
- Early identification and a general overhaul of routing logic
- Resource syncing refactor
- New tenancy bootstrappers
If you’re upgrading from v3, the main changes that will affect you are:
- Namespace changes (mostly database-related things being moved to a dedicated namespace). These are easily resolved with any modern IDE
- New config structure. You will have to delete and republish it (and then re-apply your changes, if any). It’s recommended to also do this with the
TenancyServiceProvider - Several static properties being removed and replaced with config keys
- Changes to routing logic (if you’re using universal routes)
Diff: d0de09a...master
New features
Section titled “New features”- Tenant schema dump (
tenants:dump) command7d98ebb#807a1a976c#985cb7567a#1015ea19117#1019f851288 - Add Microsoft SQL Server support
cc6d4fe#715 - Add
ScoutTenancyBootstrapperf83504a#936 - Set default value for
tenantURL parameters when a tenant is identified by pathf2c6408#925 - Make
tenants:runhandle stdin prompts from subcommands409190f#9230e223e0 - Add optional
DeleteTenantStoragelistenerab5fa7a#938aa6bfb4 Add(later deprecatedBatchTenancyBootstrapperb78320b#874eff4155and removedd8af9b4)- Add
Storage::url()support7bacc50#909a7ad828222bbe48cd15db - Add tenant-specific maintenance mode
121370e#761 - Add
current()andcurrentOrFail()tenant methods42dab29#970 - Add option for dropping tenant databases on
migrate:fresh080b271#9719520cbc#1007 - Add maintenance mode events
3f60c4a#979 - Add cookie option on InitializeTenancyByRequestData
05f1b2d#98015d12e2 - Add pending tenants
198f34f#8697d3298c#10256b7458985bdbd5 - Add
DatabaseSessionBootstrapper(adds support fordatabasesession driver)5849089 - Add session state when impersonating tenant
f42f08c#1029 - Add a dedicated feature for tenant-specific mail credentials
0f892f1#989ea5a746 - Add
skip-failingoption totenants:migratecommand342c67f#945 - Allow defining the tenant connection template using array syntax
087733d#1040 - Add
RootUrlBootstrapper(changes APP_URL in CLI context, used e.g. when sending emails in queued jobs that should have links to the tenant’s domain), alsoUrlGeneratorBootstrapper617e9a7#1044fbdb13f#1068719b1be#10792c0f6155d3b3d3cecf07a - Add
BroadcastingConfigBootstrapper(makes multi-tenant broadcasting/websockets possible using tenant-specific keys)d7a4982#1027, Reverb:590360b - Add
BroadcastChannelPrefixBootstrapper(makes multi-tenant broadcasting/websockets by prefixing channel names)c34952fca400b500a00a2, Reverb:252e337, helper change:a37dc9b - Add cache prefix mode for separating tenant caches (introduces tenancy support for any cache driver, no longer only Redis)
bd9bbe8#1014 - Support defining domains for tenants using a
domainstring column instead of a HasMany relatione25e7b78b0bdd4 - Add
InitializeTenancyByOriginHeader9e4f33e56dd41191295f0 - Add permission-controlled MSSQL database manager
cf3d06c - Add the option to set headers and middleware in TenantAssetController
a39da04cc2d555fdd401f - Add more tenant key generators
dc4306655b1c5325360f68d87ee9 - Make tenant column used by path identification parameters configurable, general resolver refactor
0c11f29 - Add
tenant:tinkercommand6f4b9da489fbb9 - Add
Tenancy::$findWithac5948d - PostgreSQL RLS
7317d2605b602e588d1fc2057e1e, support table constraints (+ refactor for clarity and performance using dynamic programming) #1354 - Parallel migrations and other commands
1b0e7d039bcbdaf017b65075789e303b52dc6ba62b - SQLite: support named in-memory DBs
48b916e - SQLite: add DisallowSqliteAttach feature
a88a42f - Impersonation tokens: support custom models
95dd906 - Support
databasecache store tenancyecc3374 - Add
--forceoption totenants:migrate-fresh#1391 - Use
--databaseintenants:migrateas the template connection #1386
Changes
Section titled “Changes”- Respect user-defined
$onFailin the Universal Routes feature233a122#679 - Change how
tenants:runis used with argumentsa45aa8e#912 #686 - Stronger typing, minor changes to the
Tenantinterface55d0a9a8af354c87212e5d463e2da94227af98a901942d79c - Improved namespacing, all database-related logic was moved to namespaces under
Stancl\Tenancy\Database40bf28c - Refactor TenantDatabaseManagers
d2e1ce00fc1054 - Fix/improve Ignition solutions
55d0a9a3542b3f - Reverse order of tenancy bootstrappers when reverting to central context
62d19c5#932 - Make impersonation tokens require stateful guards
3bf2c39#935 - Remove configurable static property from
BelongsToTenanttrait (deprecated in PHP 8.1), replace it with a config key24146b2e5bc8dd - Refactor more static properties to config keys
ccaba05 - Improve CLI command outputs using Laravel 9+ components
e4f5b92#9685d688e668de360#1030 - Change
TenantDatabaseManager-related interfaces, add publicdatabase(): Connectionmethodfe0a322 - Make
tenants:migratedefault to configured schema patha1a976c#985 - Use a dedicated DB connection for creating/deleting tenant databases
bf504f4#946 (fixes bug #515) - Improve resource syncing logic
77c5ae1#915 (fixes bug #658)22d1b20#993ea3e445#992,758fbc8#997 (adds polymorphic table for mapping resources to tenants)678468577226cf - Centralize config used by
BelongsToTenantandHasDomains, replace alltenant_idliteralsdd0f03f2a39b05(fix #998),82fa6cb - Convert publishable migrations to anonymous classes
fb2369d#1001 - Early identification (old version:
ff46bcf, new version:1d0ca27), related:4953c69e4df597df9324bc31215680b11834e51cdb, more cloning changesb789f5c0f7cd2e#1362 #1353 #1371b2f2669 - Manual mode improvements (use correct event type, add new listeners)
73c5655#1013 - Add
rememberbool column toImpersonationToken228c267#1101 - Minor
migrate:rollbackfixesb503dbf - Fix
PathTenantResolverwhen resolving tenant from cache8db27a3, relatedaa1437f - Require MySQL 8
fd6070f - Disable
asset_helper_tenancyby default, make the controller more configurablea39da04, related (rename + misc changes):657e165 - Simplify
Tenantcontract, moverun()logic toTenancy, add genericsaf3b693 - Simplify
TenantWithDatabasecontract, movetenantConfig()logice8c3c7529d1469 - Drop Laravel 10 support
ce8e74e - Add
$ignoreExistingstatic property toCreateDatabasebf1ba69 - Filesystem logic refactor
a41ad69 - Cache prefixing logic rewrite, session scoping improvements
eecf6f2, alsoScopeSessionsimprovementdc90e60 - Support non-interactive
tenancy:install8b41ea3 - SQLite: use
.sqlitesuffix if no suffix is specified836a258 - SQLite: use WAL mode for newly created DBs by default (configurable)
9ee1d63(todo: might get reverted since Laravel has config for this now) - Consume
PendingDispatchreturn values inTenancy::run()(see #1277)3c183e4b9cc63fffad2db - Queue logic refactor (todo explain in depth)
8f958d5 runForMultiple()now doesn’t execute when passed an empty array30ee4e9- URL generation, request data identification improvements (both added in v4, see previous points) #1357
- Only revert initialized bootstrappers #1385
- Use
globalCacheinCachedTenantResolver3984d64 - Fix
ViteBundlernot affectingVitestatic calls #1389
Package changes
Section titled “Package changes”- Tests now use Pest
- We now have a special queue test suite
archtechx/tenancy-queue-testerf84b22eabe1f1f - Custom Dockerfile, CI no longer uses
docker-compose - We now use phpstan
- Added API docs: api.tenancyforlaravel.com