diff --git a/src/Jobs/CreatePostgresUserForTenant.php b/src/Jobs/CreatePostgresUserForTenant.php index ea52b274..80ad9e52 100644 --- a/src/Jobs/CreatePostgresUserForTenant.php +++ b/src/Jobs/CreatePostgresUserForTenant.php @@ -37,6 +37,7 @@ class CreatePostgresUserForTenant implements ShouldQueue $name = $this->tenant->getTenantKey(); $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) { DB::statement("CREATE USER \"$name\" LOGIN PASSWORD '$password';"); }