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

Test if the db statement is incorrect

This commit is contained in:
lukinovec 2023-06-16 09:57:58 +02:00
parent 92ed22ef19
commit eb5829175e

View file

@ -32,8 +32,6 @@ class CreateRLSPoliciesForTenantTables extends Command
$table = $model->getTable();
$tenantKey = tenancy()->tenantKeyColumn();
DB::statement("DROP POLICY IF EXISTS {$table}_rls_policy ON {$table}");
if (tenancy()->modelBelongsToTenant($model)) {
DB::statement("CREATE POLICY {$table}_rls_policy ON {$table} USING ({$tenantKey}::TEXT = current_user);");
@ -48,7 +46,6 @@ class CreateRLSPoliciesForTenantTables extends Command
$parentKey = $model->$parentName()->getForeignKeyName();
$parentTable = $model->$parentName()->make()->getTable();
DB::enableQueryLog();
DB::statement("CREATE POLICY {$table}_rls_policy ON {$table} USING (
{$parentKey} IN (
SELECT id
@ -60,8 +57,11 @@ class CreateRLSPoliciesForTenantTables extends Command
))
)
)");
dump(DB::getQueryLog());
DB::disableQueryLog();
dump(DB::select('SELECT * FROM pg_policies'));
DB::statement("CREATE POLICY {$table}_rls_policy ON {$table} USING ({$tenantKey}::TEXT = current_user);");
dd(DB::select('SELECT * FROM pg_policies'));
$this->enableRls($table);