mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 14:34:04 +00:00
Use "Postgres user" instead of "Postgres role"
This commit is contained in:
parent
26eafd30ba
commit
e000386d1f
3 changed files with 9 additions and 9 deletions
|
|
@ -14,7 +14,7 @@ use Illuminate\Queue\SerializesModels;
|
|||
use Illuminate\Support\Facades\DB;
|
||||
use Stancl\Tenancy\Database\Contracts\TenantWithDatabase;
|
||||
|
||||
class CreatePostgresRoleForTenant implements ShouldQueue
|
||||
class CreatePostgresUserForTenant implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
|
@ -39,9 +39,9 @@ class CreatePostgresRoleForTenant implements ShouldQueue
|
|||
$password = $this->tenant->database()->getPassword() ?? 'password';
|
||||
|
||||
try {
|
||||
DB::statement("CREATE ROLE \"$name\" LOGIN PASSWORD '$password';");
|
||||
DB::statement("CREATE USER \"$name\" LOGIN PASSWORD '$password';");
|
||||
} catch (QueryException $exception) {
|
||||
// Skip creating Postgres role if it already exists
|
||||
// Skip creating Postgres user if it already exists
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ use Illuminate\Queue\SerializesModels;
|
|||
use Illuminate\Support\Facades\DB;
|
||||
use Stancl\Tenancy\Database\Contracts\TenantWithDatabase;
|
||||
|
||||
class DeleteTenantsPostgresRole implements ShouldQueue
|
||||
class DeleteTenantsPostgresUser implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
|
|
@ -37,12 +37,12 @@ class DeleteTenantsPostgresRole implements ShouldQueue
|
|||
{
|
||||
$tenantKey = $this->tenant->getTenantKey();
|
||||
|
||||
// Revoke all permissions of a role before dropping it
|
||||
// Revoke all permissions of a Postgres user before dropping it
|
||||
try {
|
||||
DB::statement("DROP OWNED BY \"{$tenantKey}\";");
|
||||
DB::statement("DROP ROLE \"{$tenantKey}\";");
|
||||
DB::statement("DROP USER \"{$tenantKey}\";");
|
||||
} catch (QueryException $exception) {
|
||||
// Skip dropping permissions if the role doesn't exist
|
||||
// Skip dropping permissions if the user doesn't exist
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue