diff --git a/assets/TenancyServiceProvider.stub.php b/assets/TenancyServiceProvider.stub.php index 57320431..287b0be0 100644 --- a/assets/TenancyServiceProvider.stub.php +++ b/assets/TenancyServiceProvider.stub.php @@ -30,7 +30,7 @@ class TenancyServiceProvider extends ServiceProvider // Jobs\SeedDatabase::class, // Jobs\CreateStorageSymlinks::class, - // Jobs\CreatePostgresRoleForTenant::class, + // Jobs\CreatePostgresUserForTenant::class, // Your own jobs to prepare the tenant. // Provision API keys, create S3 buckets, anything you want! @@ -56,7 +56,7 @@ class TenancyServiceProvider extends ServiceProvider Events\TenantDeleted::class => [ JobPipeline::make([ Jobs\DeleteDatabase::class, - // Jobs\DeleteTenantsPostgresRole::class, + // Jobs\DeleteTenantsPostgresUser::class, // Jobs\RemoveStorageSymlinks::class, ])->send(function (Events\TenantDeleted $event) { return $event->tenant; diff --git a/src/Jobs/CreatePostgresRoleForTenant.php b/src/Jobs/CreatePostgresUserForTenant.php similarity index 84% rename from src/Jobs/CreatePostgresRoleForTenant.php rename to src/Jobs/CreatePostgresUserForTenant.php index f868bcbe..74c09fb7 100644 --- a/src/Jobs/CreatePostgresRoleForTenant.php +++ b/src/Jobs/CreatePostgresUserForTenant.php @@ -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 } } } diff --git a/src/Jobs/DeleteTenantsPostgresRole.php b/src/Jobs/DeleteTenantsPostgresUser.php similarity index 79% rename from src/Jobs/DeleteTenantsPostgresRole.php rename to src/Jobs/DeleteTenantsPostgresUser.php index f5a00dab..b58c7e74 100644 --- a/src/Jobs/DeleteTenantsPostgresRole.php +++ b/src/Jobs/DeleteTenantsPostgresUser.php @@ -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 } } }