'Accidentially deleted rows from pg_enum

Was looking to drop an enum and did it incorrectly by deleting the rows from the pg_enum table.

I should have removed it with this:

DROP TYPE IF EXISTS "enum_Organizations_tracker_type"

In any case, I've fixed it with a migration/added the enum back, however now I am hitting this issue when querying anything in the DB:

invalid internal value for enum: 39934

39934 being the enumtypeid which was deleted. When I fixed this with a migration, new enum entries were added to the pg_enum table with new enumtypeids. I tried just changing these to the old value 39934 but this did not work.

Wondering where the old enum value is being referenced, and if there is anything I can do to fix this? Or am I just pooched/need to nuke the DB? Note that this is a local DB/not prod, so I have no backups to roll back to, however this is more just annoying more than anything.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source