What I'd suggest as an improvement that could be implemented immediately is to wrap the checks in a user-defined function like "is_system_schema(nspname name)".
pgsql-general by date:
Соглашаюсь с условиями обработки персональных данных