Closed matowang closed 4 weeks ago
I'm also running into this issue. I am using drizzle to manage two different instances of a pg db, one for staging and another for prod. I can push to the staging instance but not the prod instance. If i remove the enum value it complains about from my schema, I can push to prod, but if I add it back I still encounter the same error
I don't know how to fix it but I believe you can reproduce it by creating a Postgres enum, pushing it to the database, then if you add new items, or shuffle the tuple, then when you push again it will error.
I don't know how to fix it but I believe you can reproduce it by creating a Postgres enum, pushing it to the database, then if you add new items, or shuffle the tuple, then when you push again it will error.
You're right, the order of the enum definitions in the database must be consistent with the definitions in the Drizzle ORM, otherwise this error will occur.
I have just upagraded drizzle-kit
to latest. And this happens when I try to run push to my dev db.
+1 upgraded this morning because I needed the geometry
type and now can't seem to do a migrate because of this. Has anyone found a solution/workaround?
Is there any update on this? As a workaround I can mannually run the statements that does not involve creating duplicate enum labels by using verbose
mode of push
command. But I believe it has to be a drizzle-kit bug since it tries to add enum labels that not only defined but also used in tabels.
I'm also running into this issue with enums, since upgrading (also to get the geometry types)
someone managed to solve this? UPDATE: the workaround was deleting manually the enum ( and remove all references to it on schema ) and run push again with the enums added
Already 19 upvotes on this issue. Unfortunately I feel like Drizzle Team is not reading any Github issue :(
Having the same problem: Added a new value to the enum but Drizzle trys to add existing enums resulting in an error:
Warning You are about to execute current statements:
ALTER TYPE "product-type" ADD VALUE 'bracelet';
ALTER TYPE "product-type" ADD VALUE 'wristwatch';
ALTER TYPE "product-type" ADD VALUE 'necklace';
ALTER TYPE "product-type" ADD VALUE 'pendant';
ALTER TYPE "product-type" ADD VALUE 'ring';
error: enum label "bracelet" already exists
This issue seems to be a different one. Maybe we should reopen the same issue there because the dont seem to read any Github issues.
unfortunately this project is taking the same direction of Prisma, that is, adding lot of features without taking care of the basics of the framework, that's why JS frameworks are so easily replaced and forgotten, this issue is proof of this. I'm not complaining since it is open source, just pointing it
Eventually every one of us has the opportunity to fix the issue and make a PR tho
NEVERMIND, the Drizzle Kit repo seems to be private. I just wanted to see if I can fix it but I cant find the repository ...
I just realized that the order of the enum makes a difference! If you add values but dont change the order Drizzle Kit is pushing the new values. If you change the order Drizzle Kit wants to add new values that already exist. So probably also a quick bug fix if the repo would be public...
Please also be sure to upvote the following issue, maybe they look into the issues there? https://github.com/drizzle-team/drizzle-orm/issues/3305
Eventually every one of us has the opportunity to fix the issue and make a PR tho
NEVERMIND, the Drizzle Kit repo seems to be private. I just wanted to see if I can fix it but I cant find the repository ...
Yes, I only realized that the drizzle-kit is not fully open source once this issue oocured.
did anyone found a workaround while waiting for the Drizzle team to fix this? I fear my migrations meta definitions will be bricked if I just execute the generated SQL migration directly.
Dont change the order and it should work correctly, at least it did for me
Dont change the order and it should work correctly, at least it did for me
Not all heroes wear capes.
But yup, same for me. If you insert enums it breaks drizzle-kit, if you append them it works fine
would love a fix for this
Please try drizzle-kit@enums_fix
tag. Should be fixed there. I'll include a fix in 0.23.2 release today
Eventually every one of us has the opportunity to fix the issue and make a PR tho
NEVERMIND, the Drizzle Kit repo seems to be private. I just wanted to see if I can fix it but I cant find the repository ...
https://github.com/drizzle-team/drizzle-orm/pull/2711
Will merge it today
@AndriiSherman The second issue that I've run into in the last hour that already has a fix out! drizzle-kit@enums_fix
fixed it for me. 🎉 thank you @AndriiSherman !
Please try
drizzle-kit@enums_fix
tag. Should be fixed there. I'll include a fix in 0.23.2 release today
thanks!
was included and fixed in drizzle-kit@0.23.2
ive still got this error happening, with drizzle-kit@0.24.0, and drizzle-orm@0.33.0
yea, the latest drizzle hasn't fixed the ordering issue, you have to look up the ordering of the enum type and simply make sure the order is correct in your code as well then the error goes away, and any new enum you have to add to the bottom of the list.
I dont understand. What did the update fix exactly? Wasnt a new order after adding one property to the enum which is not at the end the main problem?
Any ETA on a fix for this annoying bug?
upgraded to latest, still the same bug
I had to downgrade to fix
Someone should mark this issue still open.
Seriously I think they dont look into the issues at all @AndriiSherman
What's a workaround for it? Downgrade to what version exactly?
I have just experienced this issue too
Can confirm, still broken.
Is anyone reading this from the Drizzle Team?? @AndriiSherman please reopen
Also can we have Drizzle Kit open source so we can fix things ourself? Drizzle team obviously not reading the Github issues
Dont change the order and it should work correctly, at least it did for me
This is the solution btw
This is not a solution, I wanted to make a design change which involved reordering enums and ran into this issue.
Saga continues..
turbo db:push --filter database git:(dev|✚10…8⚑7
• Packages in scope: database
• Running db:push in 1 packages
• Remote caching enabled
database:db:push: cache hit, replaying logs 3c12a53e155654cb
database:db:push:
database:db:push: $ drizzle-kit push --config=drizzle.config.ts --force
database:db:push: Reading config file '/Users/gokaygurcan/projects/test/packages/database/drizzle.config.ts'
database:db:push: Using 'pg' driver for database querying
[✓] Pulling schema from database...
database:db:push:
database:db:push: Warning You are about to execute current statements:
database:db:push:
database:db:push: ALTER TYPE "role" ADD VALUE 'admin';
database:db:push:
database:db:push: error: enum label "role" already exists
database:db:push: at /Users/gokaygurcan/projects/test/node_modules/pg-pool/index.js:45:11
database:db:push: at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
database:db:push: at async Object.query (/Users/gokaygurcan/projects/test/node_modules/drizzle-kit/bin.cjs:71880:26)
database:db:push: at async pgPush (/Users/gokaygurcan/projects/test/node_modules/drizzle-kit/bin.cjs:74835:13)
database:db:push: at async Object.handler (/Users/gokaygurcan/projects/test/node_modules/drizzle-kit/bin.cjs:83713:9)
database:db:push: at async run (/Users/gokaygurcan/projects/test/node_modules/drizzle-kit/bin.cjs:82064:7) {
database:db:push: length: 96,
database:db:push: severity: 'ERROR',
database:db:push: code: '42710',
database:db:push: detail: undefined,
database:db:push: hint: undefined,
database:db:push: position: undefined,
database:db:push: internalPosition: undefined,
database:db:push: internalQuery: undefined,
database:db:push: where: undefined,
database:db:push: schema: undefined,
database:db:push: table: undefined,
database:db:push: column: undefined,
database:db:push: dataType: undefined,
database:db:push: constraint: undefined,
database:db:push: file: 'pg_enum.c',
database:db:push: line: '348',
database:db:push: routine: 'AddEnumLabel'
database:db:push: }
Tasks: 1 successful, 1 total
Cached: 1 cached, 1 total
Time: 174ms >>> FULL TURBO
Well, at least it fails fast.
Can someone remind me why this issue was closed again?
We are merging a fix to add labels, and we will also include fixes for reordering and other enum manipulations. Additionally, reordering of enum values will involve dropping the enum, altering the column type to string, adding the new enum, and then changing the column type back to the updated enum
one PR: https://github.com/drizzle-team/drizzle-orm/pull/3076 another PR will be included soon
Please try drizzle-kit@0.26.0
I just realized that the order of the enum makes a difference! If you add values but dont change the order Drizzle Kit is pushing the new values. If you change the order Drizzle Kit wants to add new values that already exist. So probably also a quick bug fix if the repo would be public...
Please also be sure to upvote the following issue, maybe they look into the issues there? drizzle-team/drizzle-orm#3305
Worked for me
Please try
drizzle-kit@0.26.0
Hey, can confirm it fixes the issue for me (After I made changes in order to trigger the issue before updating my Drizzle packages). Thanks <3
@AndriiSherman after upgrading to drizzle-kit@0.26.0 it seems to want to recreate the types. This will fail since the types already exist.
Is there a possible work around?
I have the same issue on the enum
error: type "..." already exists.
This needs correction
I thought I was experiencing the same issue, but it happened that the enum actually existed as the migration-files had been overwritten directly. Run this query in the database ensure the enum doesn't exist:
SELECT e.enumlabel AS enum_value
FROM pg_type t
JOIN pg_enum e ON t.oid = e.enumtypid
WHERE t.typname = <YOUR_ENUM>;
i still have this issue Ricardo Santos
On Mon, Oct 28, 2024 at 12:20 PM Ole August Støle @.***> wrote:
I thought I was experiencing the same issue, but it happened that the enum actually existed as the migration-files had been overwritten directly. Run this query in the database ensure the enum doesn't exist:
SELECT e.enumlabel AS enum_value FROM pg_type t JOIN pg_enum e ON t.oid = e.enumtypid WHERE t.typname = 'transactionTypeEnum';
— Reply to this email directly, view it on GitHub https://github.com/drizzle-team/drizzle-orm/issues/2389#issuecomment-2441434253, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHIREUF37WS4LOMGF5PVHXLZ5YMXTAVCNFSM6AAAAABIOBK2YGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBRGQZTIMRVGM . You are receiving this because you commented.Message ID: @.***>
getting this error with drizzle-kit@0.28.0
What version of
drizzle-orm
are you using?0.30.9
What version of
drizzle-kit
are you using?0.21.2
Describe the Bug
This bug happens every so often. Is there a work around?
pnpm drizzle-kit push drizzle-kit: v0.21.2 drizzle-orm: v0.30.9
No config path provided, using default path
Using 'pg' driver for database querying
Warning You are about to execute current statements:
ALTER TYPE "job_name" ADD VALUE 'SET_PCS_POWER_KW';
error: enum label "SET_PCS_POWER_KW" already exists
kit@0.21.2/node_modules/drizzle-kit/bin.cjs:113632:7) { length: 102, severity: 'ERROR', code: '42710', detail: undefined, hint: undefined, position: undefined, internalPosition: undefined, internalQuery: undefined, where: undefined, schema: undefined, table: undefined, column: undefined, dataType: undefined, constraint: undefined, file: 'pg_enum.c', line: '293', routine: 'AddEnumLabel' }
Expected behavior
No response
Environment & setup
No response