phinx icon indicating copy to clipboard operation
phinx copied to clipboard

Support enums in postgres

Open rbalik opened this issue 1 year ago • 5 comments

Hi there, basically just checking to see if this something you all would consider adding. Postgres supports enums on columns but it's a two-step process where you make an enum type and then you set that type on the create like this:

CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy');
CREATE TABLE person (
    name text,
    current_mood mood
);

More information at https://www.postgresql.org/docs/current/datatype-enum.html

rbalik avatar Jan 21 '24 18:01 rbalik

So far CakePHP has never used enums as such, as they have a lot of disadvantages. Instead tinyint(2) and a PHP internal mapping has been used to better handle this kind of use case.

But that said a PR for such a feature is welcome. Folks outside of CakePHP or in general interested in using this feature despite the disadvantages sure could find it useful.

dereuromark avatar Jan 21 '24 19:01 dereuromark

The problem with PostgreSQL enums is the fact, that (only in PostgreSQL) they are sort of a custom column type instead of a generic enum column type (like in MySQL 8) which has additional data inside it.

LordSimal avatar Jan 21 '24 20:01 LordSimal

Right yeah, I showed that in my example. It's definitely more annoying to deal with so I understand if lower down the list. Figured I'd check what you all were thinking though.

rbalik avatar Jan 21 '24 21:01 rbalik

Like I said: it would have to be a community PR As seen from other tickets: there is no big incentive for those topics to be addressed from maintainer side. Best to do it yourself if u are interested in this feature

dereuromark avatar Jan 21 '24 21:01 dereuromark

Got it. Thanks

rbalik avatar Jan 21 '24 21:01 rbalik