From 61519ecec34c41efc7b9e72f782da353204ba0cf Mon Sep 17 00:00:00 2001 From: lukinovec Date: Wed, 31 May 2023 07:53:21 +0200 Subject: [PATCH] Wrap makeModelUseRls() in transaction --- src/Commands/CreateRLSPoliciesForTenantTables.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Commands/CreateRLSPoliciesForTenantTables.php b/src/Commands/CreateRLSPoliciesForTenantTables.php index a018dadc..445e84ce 100644 --- a/src/Commands/CreateRLSPoliciesForTenantTables.php +++ b/src/Commands/CreateRLSPoliciesForTenantTables.php @@ -20,7 +20,7 @@ class CreateRLSPoliciesForTenantTables extends Command /** @var Model $model */ $model = new $modelClass; - $this->makeModelUseRls($model); + DB::transaction(fn () => $this->makeModelUseRls($model)); } return Command::SUCCESS; @@ -79,9 +79,7 @@ class CreateRLSPoliciesForTenantTables extends Command protected function enableRls(string $table): void { - DB::transaction(function () use ($table) { - DB::statement("ALTER TABLE {$table} ENABLE ROW LEVEL SECURITY"); - DB::statement("ALTER TABLE {$table} FORCE ROW LEVEL SECURITY"); - }); + DB::statement("ALTER TABLE {$table} ENABLE ROW LEVEL SECURITY"); + DB::statement("ALTER TABLE {$table} FORCE ROW LEVEL SECURITY"); } }