mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 08:44:02 +00:00
* Initial draft * Apply fixes from StyleCI * Use CI on master branch too * Pass correct argument to queued DB creators/deleters * Apply fixes from StyleCI * Remove new interface from MySQLDBManager * Make phpunit run * Apply fixes from StyleCI * Fix static property * Default databaseName * Use database transactions for creating users & granting permissions * Apply fixes from StyleCI * Get old tests to pass * Apply fixes from StyleCI * Add tests for PermissionControlledMySQLDatabaseManager * Apply fixes from StyleCI * Write test for extra config, fix bug with extra config * Apply fixes from StyleCI
28 lines
647 B
PHP
28 lines
647 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Stancl\Tenancy\Traits;
|
|
|
|
use Stancl\Tenancy\Tenant;
|
|
|
|
trait CreatesDatabaseUsers
|
|
{
|
|
public function createDatabase(Tenant $tenant): bool
|
|
{
|
|
return $this->database()->transaction(function () use ($tenant) {
|
|
parent::createDatabase($tenant);
|
|
|
|
return $this->createUser($tenant->database());
|
|
});
|
|
}
|
|
|
|
public function deleteDatabase(Tenant $tenant): bool
|
|
{
|
|
return $this->database()->transaction(function () use ($tenant) {
|
|
parent::deleteDatabase($tenant);
|
|
|
|
return $this->deleteUser($tenant->database());
|
|
});
|
|
}
|
|
}
|