mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 10:14:04 +00:00
Fix command
This commit is contained in:
parent
b66773da80
commit
2745f824aa
1 changed files with 6 additions and 9 deletions
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue