tenancy

Automatic multi-tenancy for Laravel. No code changes needed.

MIT License

Downloads
3M
Stars
3.5K
Committers
55

Bot releases are hidden (Show)

tenancy - v2.2.0

Published by stancl almost 5 years ago

Added

  • Conflicting routes - you may now use the same URLs in the tenant & central parts of the app docs
  • Universal routes - you may now use the same routes (e.g. Auth::routes() or Nova routes) for both the tenant & central part of the app docs
  • Much richer event system (docs), allowing for things like:
    • jobs to be put into the queue chain of the job that creates tenant DBs, without race conditions
    • seeding tenant data on creation
    • created_at/updated_at/deleted_at timestamps
  • Optional Timestamps feature docs
  • TenantAwareCommand trait for commands docs
  • Find tenant by any key docs
  • Deleting keys from tenant storage docs
  • Better IDE support for global helpers (tenancy() & tenant())

Fixes

  • tenants:migrate now accepts --path
tenancy - v2.1.2

Published by stancl about 5 years ago

Patch release.

  • Don't purge central connections - fix issue caused by writing a regression test #192
tenancy - v2.1.1

Published by stancl about 5 years ago

Patch release.

  • Don't purge central connections #189
  • Respect custom columns during tenant creation #191
  • Create routes/tenant.php only if the file does not exist #188
tenancy - v2.1.0

Published by stancl about 5 years ago

2.1.0

Added:

  • Automatic seeding after tenant creation can now be enabled
  • $tenant->run() -- run a closure inside a tenant's environment Documentation
  • Nova integration Documentation
  • spatie/laravel-activitylog integration Documentation
  • Central queue connections Documentation
  • The MySQLDatabaseManager now respects your charset & collation instead of always using utf8mb & utf8mb4_unicode_ci

Bug fixes:

  • Fixed: Tenant routes are now registered even in HTTP tests.
  • Fixed: The queued DB creators, deletors and migrators were causing serialization issues under some conditions.

Bug fixes with breaking changes:

Queue race conditions

When both DB creation & migration were queued (after tenant creation), a race condition could happen, i.e. the migrate job would be executed before the create DB job.

Breaking change: The queue_automatic_migration configuration key was dropped. Whether post-creation migrations & seeding should be queued now depends on whether the DB creation is queued.

InitializeTenancy middleware

The InitializeTenancy middleware was part of the route middleware stack, which means it was executed after controller constructors. This could result in problems when a dependency (constructor argument) was injected before tenancy was initialized.

The InitializeTenancy middleware is now executed as part of the global middleware stack. That stack doesn't know whether the current route is a tenant route or a central route, it only knows if the current domain is a tenant domain. If tenancy was initialized on a non-tenant route (= if a central route was visited on a tenant domain), the PreventAccessFromTenantDomains middleware aborts the request.

Breaking change: If you applied the InitializeTenancy middleware on some routes manually, change it to 'tenancy' -- a middleware group. The PreventAccessFromTenantDomains middleware uses the presence of that middleware group as a check for whether a route is marked as tenant or not.

tenancy - v2.0.1

Published by stancl about 5 years ago

Patch release.

  • Use Config\Repository contract instead of concrete #157
  • Fix reference to tenancy.tenant_route_namespace config in the route SP #161
tenancy - v2.0.0

Published by stancl about 5 years ago

🎉 2.0.0

Main changes

  • Tenant objects are now used, instead of arrays, to represent tenants. See the Tenants page.
  • Tenants can now have multiple domains, so a new domains table is used by the DB storage driver.
  • The uuid property on tenants is now id.
  • tenancy() helper now returns an instance of TenantManager while the tenant() helper returns an instance of the current Tenant. If no Tenant has been identified, null is returned. Same with the Tenancy and Tenant facades.
  • Event listeners/hooks have a new syntax: Tenancy::eventListener('bootstrapping', function () {})
  • The tenancy bootstrapping logic has been extracted into separate classes, such as DatabaseTenancyBootstrapper, CacheTenancyBootstrapper etc.
  • A concept of Features was introduced. They're classes that provide additional functionality - functionality that is not necessary to bootstrap tenancy.
  • predis support was dropped. Laravel will drop predis support in 7.x.
  • There is new syntax for creating and interacting with tenants, be sure to read those documentation pages again.
  • The config was changed a lot, so you should publish and configure it again.
    You can publish the configuration like this:
    php artisan vendor:publish --provider='Stancl\Tenancy\TenancyServiceProvider' --tag=config
    

DB storage driver

  • The uuid column in the tenants table was renamed to id. The domain column was dropped.
  • A new migration was added to create the domains table. The old migration was renamed, so if you publish migrations again, be sure to delete the old migration, to avoid creating the table twice.
    You can publish migrations like this:
    php artisan vendor:publish --provider='Stancl\Tenancy\TenancyServiceProvider' --tag=migrations
    

Redis storage driver

  • The uuid keys are now id.
  • The domain key was dropped.
  • The _tenancy_domains key is used to store an array of domains that belong to the tenant.

New Features

tenancy - v2.0.0-rc2

Published by stancl about 5 years ago

Bug fixes, config was restructured, tenants:migrate-fresh was added, TenantConfig feature was added, UUID generator was moved to a different namespace.

tenancy - v2.0.0-rc1

Published by stancl about 5 years ago

Changelog will be published when v2.0.0 is released.

The documentation is updated for v2.0.0-rc1.

tenancy - v1.8.0

Published by stancl about 5 years ago

Added

  • Multi-tenant Jobs: Jobs are now automatically multi-tenant. The documentation page covers the small tweaks you will have to make to your config to get multi-tenant jobs to work.
  • Telescope Integration: You can read more about this on the documentation page.
  • Horizon Integration: You can read more about this on the documentation page.
  • Tenant Redirect and Custom ID schemes: You can now easily redirect to tenant domains. You can also use a custom tenant ID scheme if you don't like UUIDs. You can read about these features here.

Fixed

  • #112 PostgreSQL Database creation error.

Code

  • Strict types declaration is now used in every file.
tenancy - v1.7.0

Published by stancl about 5 years ago

Added:

  • DB storage driver - you don't have to use Redis to store tenants anymore. Relational databases are now supported as well. more info
  • tenancy:install will do everything except DB/Redis connection creation for you. It will make changes to Http/Kernel.php, create routes/tenant.php, publish config, and (optionally) publish the migration. more info
  • tenants:run more info
  • New documentation: https://stancl-tenancy.netlify.com
  • Custom tenant DB names more info
  • stancl/tenancy events more info

Fixed:

  • #89 Command "tenants:migrate" cannot be found when used in app code
  • #87 Unable to migrate multiple tenants at once when using MySQL
  • #96 Issue w/ redis->scan() in getAllTenants logic.