2023-02-08 05:58:45 -05:00
|
|
|
/* 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}
|
2023-03-08 06:16:42 -05:00
|
|
|
as restrictive
|
2023-02-08 05:58:45 -05:00
|
|
|
using (tenant_id = (select id from tenants where db_user = current_user));
|
2023-03-08 06:16:42 -05:00
|
|
|
|
|
|
|
create policy ${name}_modification on ${name}
|
|
|
|
using (true);
|