mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-13 23:54:03 +00:00
[3.x] DB users (#382)
* 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
This commit is contained in:
parent
60665517a0
commit
3bb2759fe2
41 changed files with 756 additions and 286 deletions
16
src/Contracts/ManagesDatabaseUsers.php
Normal file
16
src/Contracts/ManagesDatabaseUsers.php
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Tenancy\Contracts;
|
||||
|
||||
use Stancl\Tenancy\DatabaseConfig;
|
||||
|
||||
interface ManagesDatabaseUsers extends TenantDatabaseManager
|
||||
{
|
||||
public function createUser(DatabaseConfig $databaseConfig): bool;
|
||||
|
||||
public function deleteUser(DatabaseConfig $databaseConfig): bool;
|
||||
|
||||
public function userExists(string $username): bool;
|
||||
}
|
||||
13
src/Contracts/ModifiesDatabaseNameForConnection.php
Normal file
13
src/Contracts/ModifiesDatabaseNameForConnection.php
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Tenancy\Contracts;
|
||||
|
||||
/**
|
||||
* Used by sqlite to wrap database name in database_path().
|
||||
*/
|
||||
interface ModifiesDatabaseNameForConnection
|
||||
{
|
||||
public function getDatabaseNameForConnection(string $original): string;
|
||||
}
|
||||
|
|
@ -4,23 +4,26 @@ declare(strict_types=1);
|
|||
|
||||
namespace Stancl\Tenancy\Contracts;
|
||||
|
||||
use Stancl\Tenancy\Tenant;
|
||||
|
||||
interface TenantDatabaseManager
|
||||
{
|
||||
/**
|
||||
* Create a database.
|
||||
* Return the config key that separates databases (e.g. 'database' or 'schema').
|
||||
*
|
||||
* @param string $name Name of the database.
|
||||
* @return bool
|
||||
* @return string
|
||||
*/
|
||||
public function createDatabase(string $name): bool;
|
||||
public function getSeparator(): string;
|
||||
|
||||
/**
|
||||
* Create a database.
|
||||
*/
|
||||
public function createDatabase(Tenant $tenant): bool;
|
||||
|
||||
/**
|
||||
* Delete a database.
|
||||
*
|
||||
* @param string $name Name of the database.
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteDatabase(string $name): bool;
|
||||
public function deleteDatabase(Tenant $tenant): bool;
|
||||
|
||||
/**
|
||||
* Does a database exist.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue