-
-
Notifications
You must be signed in to change notification settings - Fork 740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG]: drizzle-kit migrate fail "applying migrations...error: column "authorid" does not exist" #2423
Comments
I just ran into a similar issue that happens with drizzle-kit push as well. appears to be an issue with the setting up indexes. As a simple example:
This generates the error: "error: column "testid" does not exist Additionally index does not seem to like dashes in the column name, so |
oh interesting..but I don't want to use all lower case column name.. i hope drizzle team can fix this soon. I really need to use the new features in drizzle 0.31.0 to create compound index with desc() inside the index().on()...but this bug is preventing me to upgrate to 0.31.0 thanks very much for your response! this is helpful information for me! |
This happens with PostgreSQL. By default, PostgreSQL converts all tokens to lowercase unless they are wrapped in double quotes. The solution is to keep your keys in the required case; however, database columns need to be lowercase for PostgreSQL. |
Oh! Thanks for the explanation. It seems it is best practice to use snake_case for column names in postgres (https://wiki.postgresql.org/wiki/Don't_Do_This#Don.27t_use_upper_case_table_or_column_names). I didn't know this before hehe. This makes sense then. However, the previous version of drizzle (kit 21.0 , orm 30.10) worked fine on this. Anyway I'll change to use snake case to follow the best practice. |
Related Issue: #2413 |
Should be fixed in |
Thank you for fixing this!!
…________________________________
From: Andrii Sherman ***@***.***>
Sent: Friday, June 7, 2024 11:15:32 PM
To: drizzle-team/drizzle-orm ***@***.***>
Cc: Weixuan Fu ***@***.***>; Author ***@***.***>
Subject: Re: [drizzle-team/drizzle-orm] [BUG]: drizzle-kit migrate fail "applying migrations...error: column "authorid" does not exist" (Issue #2423)
Should be fixed in ***@***.***
—
Reply to this email directly, view it on GitHub<#2423 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AEMEEOK233YHQF5ZIVYF6Y3ZGHFBJAVCNFSM6AAAAABIVE2KTKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJVGA2DMNJZGA>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
im getting this same error but because a type enum export const fileTypeEnum = pgEnum('fileType', ['image/jpeg', 'application/pdf']) this is the table export const files = pgTable('files', {
id: text('id').primaryKey(),
roId: text('roId').notNull(),
name: text('name').notNull(),
key: text('key').notNull(),
url: text('url').notNull(),
type: fileTypeEnum('type').notNull(),
createdAt: timestamp('createdAt').defaultNow().notNull()
}) and this is the error [⡿] applying migrations...PostgresError: type "filetype" does not exist
at ErrorResponse (/home/alejandro/.dev/toyota-ro/node_modules/drizzle-kit/bin.cjs:79677:27)
at handle (/home/alejandro/.dev/toyota-ro/node_modules/drizzle-kit/bin.cjs:79454:7)
at Socket.data (/home/alejandro/.dev/toyota-ro/node_modules/drizzle-kit/bin.cjs:79277:9)
at Socket.emit (node:events:517:28)
at addChunk (node:internal/streams/readable:368:12)
at readableAddChunk (node:internal/streams/readable:341:9)
at Readable.push (node:internal/streams/readable:278:10)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
at TCP.callbackTrampoline (node:internal/async_hooks:128:17) {
severity_local: 'ERROR',
severity: 'ERROR',
code: '42704',
file: 'parse_type.c',
line: '270',
routine: 'typenameType'
} |
Same here! any fixes? :( |
TL;DR Delete your migrations folder and generate the migrations again. It fixed the issue for me. Detailed I faced the same error today. In my case, I initially missed the To fix that, I prefixed the I simply deleted the migrations directory and generated new migrations. It fixed the issue. Hope it helps. |
Worked for me by adding export, ty ! |
What version of
drizzle-orm
are you using?0.31.0
What version of
drizzle-kit
are you using?0.22.1
Describe the Bug
npx drizzle-kit migrate
throws error and fail to create any table in my postgres db , whilenpx drizzle-kit push
throws error but can create tables in my postgres dbBefore I upgrade to 0.22.1, this issue doesn't occur, I was at:
drizzle-kit: v0.21.2
drizzle-orm: v0.30.10
After upgrading to drizzle-kit: v0.22.1, this issue happened.
drizzle-kit: v0.22.1
drizzle-orm: v0.31.0
Expected behavior
No response
Environment & setup
No response
The text was updated successfully, but these errors were encountered: