1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 07:04:03 +00:00

[1.7.0] Add DB storage driver (#82)

This commit is contained in:
Samuel Štancl 2019-08-16 14:36:49 +02:00 committed by GitHub
parent 674f4b3f9a
commit 9df78eb9c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 375 additions and 25 deletions

View file

@ -366,7 +366,35 @@ Note that deleting a tenant doesn't delete his database. You can do this manuall
## Storage driver
Currently, only Redis is supported, but you're free to code your own storage driver which follows the `Stancl\Tenancy\Interfaces\StorageDriver` interface. Just point the `tenancy.storage_driver` setting at your driver.
### Database
The database storage driver lets you store information about tenants in a relational database like MySQL, PostgreSQL and SQLite.
To use this storage driver, publish the `create_tenants_table` migration:
```
php artisan vendor:publish --provider='Stancl\Tenancy\TenancyServiceProvider' --tag=migrations
```
By default, the table contains only `uuid`, `domain` and `data` columns.
The `data` column is used to store information about a tenant, such as their selected plan, in JSON form. This package does not store anything in the column by default.
You can store specific keys in your own columns. This is useful if you want to use RDBMS features like indexes.
If you don't need any custom columns, you can skip the next section and run:
```
php artisan migrate
```
#### Adding your own columns
To add your own columns, TODO.
### Redis
Using Redis as your storage driver is recommended due to its low overhead compared to a relational database like MySQL.
**Note that you need to configure persistence on your Redis instance** if you don't want to lose all information about tenants.