diff --git a/src/Commands/CreateRLSPoliciesForTenantTables.php b/src/Commands/CreateRLSPoliciesForTenantTables.php index 13110051..a018dadc 100644 --- a/src/Commands/CreateRLSPoliciesForTenantTables.php +++ b/src/Commands/CreateRLSPoliciesForTenantTables.php @@ -31,7 +31,7 @@ class CreateRLSPoliciesForTenantTables extends Command $table = $model->getTable(); $tenantKey = tenancy()->tenantKeyColumn(); - DB::transaction(fn () => DB::statement("DROP POLICY IF EXISTS {$table}_rls_policy ON {$table}")); + DB::statement("DROP POLICY IF EXISTS {$table}_rls_policy ON {$table}"); if (! Schema::hasColumn($table, $tenantKey)) { // Table is not directly related to tenant @@ -43,7 +43,7 @@ class CreateRLSPoliciesForTenantTables extends Command $this->components->info("Table '$table' is not related to tenant. Make sure $modelName uses the BelongsToPrimaryModel trait."); } } else { - DB::transaction(fn () => DB::statement("CREATE POLICY {$table}_rls_policy ON {$table} USING ({$tenantKey}::TEXT = current_user);")); + DB::statement("CREATE POLICY {$table}_rls_policy ON {$table} USING ({$tenantKey}::TEXT = current_user);"); $this->enableRls($table); @@ -62,7 +62,7 @@ class CreateRLSPoliciesForTenantTables extends Command $parentModel = $model->$parentName()->make(); $parentTable = str($parentModel->getTable())->toString(); - DB::transaction(fn () => DB::statement("CREATE POLICY {$table}_rls_policy ON {$table} USING ( + DB::statement("CREATE POLICY {$table}_rls_policy ON {$table} USING ( {$parentKey} IN ( SELECT id FROM {$parentTable} @@ -72,7 +72,7 @@ class CreateRLSPoliciesForTenantTables extends Command WHERE id = {$parentKey} )) ) - )")); + )"); $this->enableRls($table); } diff --git a/src/Jobs/CreatePostgresUserForTenant.php b/src/Jobs/CreatePostgresUserForTenant.php index 9cc8cdb6..55f33fc7 100644 --- a/src/Jobs/CreatePostgresUserForTenant.php +++ b/src/Jobs/CreatePostgresUserForTenant.php @@ -39,7 +39,7 @@ class CreatePostgresUserForTenant implements ShouldQueue // Create the user only if it doesn't already exist if (! count(DB::select("SELECT usename FROM pg_user WHERE usename = '$name';")) > 0) { - DB::transaction(fn () => DB::statement("CREATE USER \"$name\" LOGIN PASSWORD '$password';")); + DB::statement("CREATE USER \"$name\" LOGIN PASSWORD '$password';"); } $this->grantPermissions((string) $name); diff --git a/tests/PostgresTest.php b/tests/PostgresTest.php index 8ff819f3..06263ab7 100644 --- a/tests/PostgresTest.php +++ b/tests/PostgresTest.php @@ -114,7 +114,7 @@ test('correct rls policies get created', function () { // Drop all existing policies to check if the command creates policies for multiple tables foreach ($getRlsPolicies() as $policy) { - DB::transaction(fn () => DB::statement("DROP POLICY IF EXISTS {$policy->policyname} ON {$policy->tablename}")); + DB::statement("DROP POLICY IF EXISTS {$policy->policyname} ON {$policy->tablename}"); } expect($getRlsPolicies())->toHaveCount(0);