ERole AS ENUM ('SuperAdmin','Admin','Moderator','Doctor', 'Patient');
and another enum in another database with the same name
CREATE TYPE ERole AS ENUM ('Admin','Moderator','User');
Why they collide with each other? I want to create the enums encapsulated inside database, not global.
Because the same names?
WFM. I suspect you're just connecting/testing in a wrong database/server/whatever.
Try: drop type if exists ERole; CREATE TYPE ERole AS ENUM ('Admin','Moderator','User');
Then it throws constraint error saying dropping Erole will cause data inconsistency. It is basically pointing to my other enum in the another DB. I don't understand why enums are created globally instead of DB specific?
Gotta check that.
They are not — just re-check everything.
Try: SELECT n.nspname AS schema, pg_catalog.format_type ( t.oid, NULL ) AS name, t.typname AS internal_name, CASE WHEN t.typrelid != 0 THEN CAST ( 'tuple' AS pg_catalog.text ) WHEN t.typlen < 0 THEN CAST ( 'var' AS pg_catalog.text ) ELSE CAST ( t.typlen AS pg_catalog.text ) END AS size, pg_catalog.array_to_string ( ARRAY( SELECT e.enumlabel FROM pg_catalog.pg_enum e WHERE e.enumtypid = t.oid ORDER BY e.oid ), E'\n' ) AS elements, pg_catalog.obj_description ( t.oid, 'pg_type' ) AS description FROM pg_catalog.pg_type t LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace WHERE ( t.typrelid = 0 OR ( SELECT c.relkind = 'c' FROM pg_catalog.pg_class c WHERE c.oid = t.typrelid ) ) AND NOT EXISTS ( SELECT 1 FROM pg_catalog.pg_type el WHERE el.oid = t.typelem AND el.typarray = t.oid ) AND n.nspname <> 'pg_catalog' AND n.nspname <> 'information_schema' AND pg_catalog.pg_type_is_visible ( t.oid ) ORDER BY 1, 2;
Tnx mate. This was the issue 🤣. I forgot to switch db connection string
Обсуждают сегодня