================================================================================================================================================================

Postgres: Create enum if not exists

postgres sql

In postgres there is nothing like create table if not exists for enums. Workaround:

DO
$$
    BEGIN
        CREATE TYPE request_type AS ENUM ('request_type1', 'request_type2');
    EXCEPTION
        WHEN duplicate_object THEN null;
    END
$$;