Add option of existingType to .enum method to support repeated use of enums #2719
I was super happy to see knex supporting native enums in postgres, but when I had an enum that I used repeatedly across different columns in different tables, I was running into errors as the
Could we add a flag in the options param to not run the sql that creates the type enum?
The first time you run it you could do
And then the other times you can run
Okay, @kibertoad added some tests.
Corresponding Docs: knex/documentation#147
Since it is just using an existing type, we could allow the api to be
As it is a bit weird to have to specify an array of values that aren't actually going to be used (since the type is already created, it just utilizes the
The code would need to be changed to something like so:
Finally it looks like we are still getting a drop in code coverage. I can add more tests, but they would be like "expect error when x" tests.
… enums (knex#2719) * Update table column .enu to take an option that does not manually create the type * Add tests for psql enum existingType * Avoid utilizing enum values when using an existing type