amf
.public
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
sys_trigger_drop_role()
Parameters
Name
Type
Mode
IN
Definition
DECLARE rec record; db_user varchar(100); db_policy varchar(100); BEGIN db_user := concat('user_', old.id); db_policy := concat('tenant_policy_', old.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; RETURN NULL; -- result is ignored since this is an AFTER DELETE trigger END;