From 2745f824aa523ab4069c89616250785b5f254b15 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Thu, 27 Apr 2023 13:44:45 +0200 Subject: [PATCH] Fix command --- src/Commands/CreateRLSPoliciesForTenantTables.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/Commands/CreateRLSPoliciesForTenantTables.php b/src/Commands/CreateRLSPoliciesForTenantTables.php index 9ab749e9..6d5d27b3 100644 --- a/src/Commands/CreateRLSPoliciesForTenantTables.php +++ b/src/Commands/CreateRLSPoliciesForTenantTables.php @@ -44,21 +44,18 @@ class CreateRLSPoliciesForTenantTables extends Command )"); DB::statement("ALTER TABLE {$table} FORCE ROW LEVEL SECURITY"); - - return Command::SUCCESS; } else { $modelName = $model::class; $this->components->info("Table '$table' is not related to tenant. Make sure $modelName uses the BelongsToPrimaryModel trait."); - - return Command::FAILURE; } + } else { + DB::statement("CREATE POLICY {$table}_rls_policy ON {$table} USING ({$tenantKey}::TEXT = current_user);"); + + DB::statement("ALTER TABLE {$table} FORCE ROW LEVEL SECURITY"); + + $this->components->info("Created RLS policy for table '$table'"); } - DB::statement("CREATE POLICY {$table}_rls_policy ON {$table} USING ({$tenantKey}::TEXT = current_user);"); - - DB::statement("ALTER TABLE {$table} FORCE ROW LEVEL SECURITY"); - - $this->components->info("Created RLS policy for table '$table'"); } return Command::SUCCESS;