The list of all the queries

Enumerated or range types with the same name in different schemas

Query goal: Find cases where in different schemas there are enumerated or range types with the same name. Types are like words that can be used to construct generalized claims about the real world (table predicates). Better not to duplicate the words in the dictionary. Also make sure that this is not a duplication.
Query type: Problem detection (Each row in the result could represent a flaw in the design)
Query reliability: High (Few or no false-positive results)
Query license: MIT License
Fixing suggestion: Rename a type. In case of duplication drop the duplicates and refactor the database so that the remaining type will be used everywhere it is needed.
Data source: INFORMATION_SCHEMA+system catalog
SQL query: Click on query to copy it

WITH types AS (SELECT nspname AS type_schema, typname AS type_name, typtype
FROM pg_catalog.pg_type t INNER JOIN pg_catalog.pg_namespace n ON t.typnamespace=n.oid
WHERE typtype IN ('e','r') AND nspname NOT IN (SELECT schema_name
FROM INFORMATION_SCHEMA.schemata
WHERE schema_name<>'public' AND
schema_owner='postgres' AND schema_name IS NOT NULL))
SELECT type_name, string_agg(type_schema || '('  || CASE WHEN typtype='e' THEN 'ENUMERATED' ELSE 'RANGE' END || ')',';' ORDER BY type_schema) AS schemas, Count(*) AS number_of_types
FROM types
GROUP BY type_name
HAVING Count(*)>1
ORDER BY type_name;

SQL statements for generating SQL statements that help us to fix the problem

SQL queryDescription
WITH types AS (SELECT nspname AS type_schema, typname AS type_name
FROM pg_catalog.pg_type t INNER JOIN pg_catalog.pg_namespace n ON t.typnamespace=n.oid
WHERE typtype IN ('e','r') AND nspname NOT IN (SELECT schema_name
FROM INFORMATION_SCHEMA.schemata
WHERE schema_name<>'public' AND
schema_owner='postgres' AND schema_name IS NOT NULL)),
duplicates AS (SELECT type_name
FROM types
GROUP BY type_name
HAVING Count(*)>1)
SELECT format('DROP TYPE %1$I.%2$I;', type_schema, type_name) AS statements
FROM types
WHERE type_name IN (SELECT type_name
FROM duplicates)
ORDER BY type_schema, type_name;
Drop the duplicates.

Collections where the query belongs to

Collection nameCollection description
Find problems automaticallyQueries, that results point to problems in the database. Each query in the collection produces an initial assessment. However, a human reviewer has the final say as to whether there is a problem or not .

Categories where the query belongs to

Category nameCategory description
Comfortability of database evolutionQueries of this category provide information about the means that influence database evolution.
Data typesQueries of this category provide information about the data types and their usage.
Duplication of implementation elementsQueries of this catergory provide information about the duplication of the database objects.
NamingQueries of this category provide information about the style of naming.

Reference materials for further reading

Reference
https://refactoring.guru/smells/alternative-classes-with-different-interfaces
https://refactoring.guru/smells/duplicate-code
The corresponding code smell in case of cleaning code is "G5: Duplication". (Robert C. Martin, Clean Code)

The list of all the queries