1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 11:34:02 +00:00

Add comment

This commit is contained in:
lukinovec 2023-04-24 13:21:05 +02:00
parent 20cb3dc647
commit 39fe252ef6

View file

@ -37,6 +37,7 @@ class CreatePostgresUserForTenant implements ShouldQueue
$name = $this->tenant->getTenantKey(); $name = $this->tenant->getTenantKey();
$password = $this->tenant->database()->getPassword() ?? 'password'; $password = $this->tenant->database()->getPassword() ?? 'password';
// Create the user only if it doesn't already exist
if (count(DB::select("SELECT usename FROM pg_user WHERE usename = '$name';")) > 0) { if (count(DB::select("SELECT usename FROM pg_user WHERE usename = '$name';")) > 0) {
DB::statement("CREATE USER \"$name\" LOGIN PASSWORD '$password';"); DB::statement("CREATE USER \"$name\" LOGIN PASSWORD '$password';");
} }