1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 10:14:04 +00:00

Fix command

This commit is contained in:
lukinovec 2023-04-27 13:44:45 +02:00
parent b66773da80
commit 2745f824aa

View file

@ -44,21 +44,18 @@ class CreateRLSPoliciesForTenantTables extends Command
)"); )");
DB::statement("ALTER TABLE {$table} FORCE ROW LEVEL SECURITY"); DB::statement("ALTER TABLE {$table} FORCE ROW LEVEL SECURITY");
return Command::SUCCESS;
} else { } else {
$modelName = $model::class; $modelName = $model::class;
$this->components->info("Table '$table' is not related to tenant. Make sure $modelName uses the BelongsToPrimaryModel trait."); $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; return Command::SUCCESS;