Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Altering Enum type in Postgres gets 42883 error

I'm trying to rollback an addition that was made to this Enum named group_type in Postgres that was made to a column named type on my table groups.

In Postgress I've run,

ALTER TYPE group_type RENAME TO group_type_old;
CREATE TYPE group_type AS ENUM ('public', 'private');
ALTER TABLE groups ALTER COLUMN type DROP DEFAULT;
ALTER TABLE groups ALTER COLUMN "type" TYPE group_type USING "type"::text::group_type;

And I get the following error on the last statement,

Query 1 ERROR: ERROR:  operator does not exist: text = group_type_old
HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.

Any ideas what the issue is with my last statement?

like image 560
William Ross Avatar asked Apr 19 '26 12:04

William Ross


1 Answers

For what it's worth; I ran into this error when a value from the old enum was still mentioned as a CHECK constraint in my table, which also had the enum in a column. I solved it by dropping the constraint, changing the enum, then adding the (updated) constraint again.

like image 115
user21048898 Avatar answered Apr 22 '26 10:04

user21048898



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!