You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
...
/postgres@3.4.3/node_modules/postgres/cjs/src/connection.js:790
const error = Errors.postgres(parseError(x))
^
PostgresError: type "user_role[]" does not exist
...
The sql generated by Drizzle probably looks something like this
ALTERTABLE"users" ADD COLUMN "roles" userRoles[]
while it should be looking like
ALTERTABLE"users" ADD COLUMN "roles""userRoles"[]
I cannot figure out where Drizzle actually loads the sql from but modifying db/migrations/00000_migration_file.sql does not seem to work. For I've chosen to run the migration manually as I am not in production yet
unfurtonuately, this issue is still not resolved by drizzle-kit@0.24.0. I just tried it with Postgres:
exportconstmyEnum=pgEnum('my_enum',['VALUE1','VALUE2'])exportconstmyTable=pgTable('my_table',{id: bigserial('id',{mode: 'bigint'}).primaryKey(),enum: myEnum('enum').array().notNull(),// <-- does not work})exportconstmyTableWithDefault=pgTable('my_table_with_default',{id: bigserial('id',{mode: 'bigint'}).primaryKey(),enum: myEnum('enum').array().default([]).notNull(),// <-- does not work with default value either})
Running drizzle-kit push still throws the same error type "my_enum[]" does not exist because the generated SQL remains wrong as pointed out by @onursagir.
Maybe someone else could confirm this behavior. My local ESM setup uses workarounds mentioned here. However, I checked the correct drizzle-kit version by running pnpm drizzle-kit --version and it is indeed 0.24.0. I don't think there would be any difference in classic ("no ESM") setups.
You can work around this by using lowercase enum names.
The test cases for this use snake case, which works fine. If your enum is named using camel case (or any uppercase characters) it will trigger this bug, as @onursagir suggested here:
Postgres folds unquoted names to lowercase, so if your enum is named testEnum the sql generated looks like testenum[] which doesn't exist. Here are the existing test cases:
this still doesn't work for me on 0.24.2. I get: "day_of_week" day_of_week[] NOT NULL,
but it needs to be: "day_of_week" "flt"."day_of_week"[] NOT NULL,
So the issues are that it's not properly escaping and the schema isn't being included.
Activity
IRediTOTO commentedon Nov 30, 2023
so im not alone
dvtkrlbs commentedon Dec 1, 2023
since you are using an array you cannot have the literal as default you need to do it like this
onursagir commentedon Feb 13, 2024
The sql generated by Drizzle probably looks something like this
while it should be looking like
I cannot figure out where Drizzle actually loads the sql from but modifying
db/migrations/00000_migration_file.sqldoes not seem to work. For I've chosen to run the migration manually as I am not in production yetdiego-lipinski-de-castro commentedon Apr 3, 2024
I do not think this problem is related to the usage of .array(). I am also having this problem with the following code
Infiee commentedon Apr 24, 2024
I also encountered this issue. If I replace 'mood' with 'moodtype' or any other word, it will fail to execute!
ngethan commentedon May 24, 2024
Any resolution on this?
Lukem121 commentedon May 29, 2024
❌ Does not work:
roles: userRoleEnum("roles").array().notNull().default(["user"]),
✅ Works
roles: userRoleEnum("roles").array().default(sql
ARRAY['user']::user_role_enum[]).notNull(),mikkelwf commentedon Jun 12, 2024
Still an issue.. :/
AndriiSherman commentedon Aug 8, 2024
Should be fixed in
drizzle-kit0.24.0Please check release notes before updating
Charioteer commentedon Aug 9, 2024
Hi @AndriiSherman,
unfurtonuately, this issue is still not resolved by
drizzle-kit@0.24.0. I just tried it with Postgres:Running
drizzle-kit pushstill throws the same errortype "my_enum[]" does not existbecause the generated SQL remains wrong as pointed out by @onursagir.Maybe someone else could confirm this behavior. My local ESM setup uses workarounds mentioned here. However, I checked the correct
drizzle-kitversion by runningpnpm drizzle-kit --versionand it is indeed0.24.0. I don't think there would be any difference in classic ("no ESM") setups.andygott commentedon Aug 30, 2024
You can work around this by using lowercase enum names.
The test cases for this use snake case, which works fine. If your enum is named using camel case (or any uppercase characters) it will trigger this bug, as @onursagir suggested here:
#1564 (comment)
Postgres folds unquoted names to lowercase, so if your enum is named
testEnumthe sql generated looks liketestenum[]which doesn't exist. Here are the existing test cases:drizzle-orm/drizzle-kit/tests/pg-array.test.ts
Line 302 in c8359a1
I think the problem is here:
https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/pg-core/columns/common.ts#L305
As far as I can tell (I've only had a quick look) quoting the enum name in
PgArrayshould fix it:fendyk commentedon Aug 30, 2024
I tried
drizzle-kit@0.24.2:tested with postgres and works.
agreenspan commentedon Sep 24, 2024
This is still broken for PascalCase enums
bestickley commentedon Sep 30, 2024
this still doesn't work for me on 0.24.2. I get:
"day_of_week" day_of_week[] NOT NULL,but it needs to be:
"day_of_week" "flt"."day_of_week"[] NOT NULL,So the issues are that it's not properly escaping and the schema isn't being included.
icep0ps commentedon Oct 12, 2024
The way I worked around this is I just created the enum at the top of the migration file.
Morriz commentedon Jul 13, 2025
I notice if I don't
exportthe enum it does not get created. But addingexportdoes, even though I don't need it to be exported?nulfrost commentedon Aug 2, 2025
I think this is it, this was my enum before I added the export:
Which resulted in:
But once I added the export:
it worked lol, it's there in the docs but I assumed since I won't need this enum anywhere else it would be fine not to export it.
tl;dr for anyone else that comes across this -> add
exportto your enum