mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 17:24: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
|
|
@ -4,23 +4,30 @@ declare(strict_types=1);
|
|||
|
||||
namespace Stancl\Tenancy\TenantDatabaseManagers;
|
||||
|
||||
use Stancl\Tenancy\Contracts\ModifiesDatabaseNameForConnection;
|
||||
use Stancl\Tenancy\Contracts\TenantDatabaseManager;
|
||||
use Stancl\Tenancy\Tenant;
|
||||
|
||||
class SQLiteDatabaseManager implements TenantDatabaseManager
|
||||
class SQLiteDatabaseManager implements TenantDatabaseManager, ModifiesDatabaseNameForConnection
|
||||
{
|
||||
public function createDatabase(string $name): bool
|
||||
public function getSeparator(): string
|
||||
{
|
||||
return 'database';
|
||||
}
|
||||
|
||||
public function createDatabase(Tenant $tenant): bool
|
||||
{
|
||||
try {
|
||||
return fclose(fopen(database_path($name), 'w'));
|
||||
return fclose(fopen(database_path($tenant->database()->getName()), 'w'));
|
||||
} catch (\Throwable $th) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteDatabase(string $name): bool
|
||||
public function deleteDatabase(Tenant $tenant): bool
|
||||
{
|
||||
try {
|
||||
return unlink(database_path($name));
|
||||
return unlink(database_path($tenant->database()->getName()));
|
||||
} catch (\Throwable $th) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -30,4 +37,9 @@ class SQLiteDatabaseManager implements TenantDatabaseManager
|
|||
{
|
||||
return file_exists(database_path($name));
|
||||
}
|
||||
|
||||
public function getDatabaseNameForConnection(string $original): string
|
||||
{
|
||||
return database_path($original);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue