amf
.public
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
sys_sp_drop_role(IN _tenant_id uuid)
Parameters
Name
Type
Mode
_tenant_id
uuid
IN
Definition
declare rec record; db_user varchar(100); db_policy varchar(100); begin db_user := concat('user_', _tenant_id); db_policy := concat('tenant_policy_', _tenant_id); if exists (select from pg_catalog.pg_roles where rolname = db_user) then for rec in select tablename from pg_tables as t where t.schemaname = 'public' and tablename not like '__EFMigrationsHistory'and tablename not like 'spatial_ref_sys' loop execute format('revoke select on table %I from %I;', rec.tablename, db_user); execute format('drop policy if exists %I on %I;', db_policy, rec.tablename); end loop; execute format('drop user %I', db_user); end if; end;