mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-06 13:34:05 +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
|
|
@ -1,47 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Tenancy\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Stancl\Tenancy\Database\Contracts\TenantWithDatabase;
|
||||
|
||||
class CreatePostgresRoleForTenant implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
protected TenantWithDatabase&Model $tenant,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$name = $this->tenant->getTenantKey();
|
||||
$password = $this->tenant->database()->getPassword() ?? 'password';
|
||||
|
||||
try {
|
||||
DB::statement("CREATE ROLE \"$name\" LOGIN PASSWORD '$password';");
|
||||
} catch (QueryException $exception) {
|
||||
// Skip creating Postgres role if it already exists
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue