mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
bdd7374d31
for enhanced security and scalability. restrictive policies can be combined with permissive policies for advanced use cases.
13 lines
474 B
SQL
13 lines
474 B
SQL
/* This SQL will run after each query files except lifecycle scripts and files that explicitly exclude `after_each`. */
|
|
|
|
create trigger set_tenant_id before insert on ${name}
|
|
for each row execute procedure set_tenant_id();
|
|
|
|
alter table ${name} enable row level security;
|
|
|
|
create policy ${name}_tenant_id on ${name}
|
|
as restrictive
|
|
using (tenant_id = (select id from tenants where db_user = current_user));
|
|
|
|
create policy ${name}_modification on ${name}
|
|
using (true);
|