error: column "id" cannot be cast automatically to type uuid

im using drizzle, and this is my schema:
export const tags = pgTable("tags", {
id: uuid("id").defaultRandom().primaryKey(),
tag: text("tag").notNull(),
});
export const tags = pgTable("tags", {
id: uuid("id").defaultRandom().primaryKey(),
tag: text("tag").notNull(),
});
when I tried pushing it:
tomri:/mnt/t/Projects/AGSCraft/binary lab/rough $ bun drizzle-kit push:pg
drizzle-kit: v0.19.13
drizzle-orm: v0.28.6

No config path provided, using default path
Reading config file '/mnt/t/Projects/AGSCraft/binary lab/rough/drizzle.config.ts'
error: column "id" cannot be cast automatically to type uuid
at Parser.parseErrorMessage (/mnt/t/Projects/AGSCraft/binary lab/rough/node_modules/drizzle-kit/index.cjs:40722:98)
at Parser.handlePacket (/mnt/t/Projects/AGSCraft/binary lab/rough/node_modules/drizzle-kit/index.cjs:40563:25)
at Parser.parse (/mnt/t/Projects/AGSCraft/binary lab/rough/node_modules/drizzle-kit/index.cjs:40487:34)
at Socket.<anonymous> (/mnt/t/Projects/AGSCraft/binary lab/rough/node_modules/drizzle-kit/index.cjs:40763:44)
at Socket.emit (node:events:515:28)
at addChunk (node:internal/streams/readable:545:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:495:3)
at Readable.push (node:internal/streams/readable:375:5)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
length: 169,
severity: 'ERROR',
code: '42804',
detail: undefined,
hint: 'You might need to specify "USING id::uuid".',
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'tablecmds.c',
line: '12332',
routine: 'ATPrepAlterColumnType'
}
tomri:/mnt/t/Projects/AGSCraft/binary lab/rough $ bun drizzle-kit push:pg
drizzle-kit: v0.19.13
drizzle-orm: v0.28.6

No config path provided, using default path
Reading config file '/mnt/t/Projects/AGSCraft/binary lab/rough/drizzle.config.ts'
error: column "id" cannot be cast automatically to type uuid
at Parser.parseErrorMessage (/mnt/t/Projects/AGSCraft/binary lab/rough/node_modules/drizzle-kit/index.cjs:40722:98)
at Parser.handlePacket (/mnt/t/Projects/AGSCraft/binary lab/rough/node_modules/drizzle-kit/index.cjs:40563:25)
at Parser.parse (/mnt/t/Projects/AGSCraft/binary lab/rough/node_modules/drizzle-kit/index.cjs:40487:34)
at Socket.<anonymous> (/mnt/t/Projects/AGSCraft/binary lab/rough/node_modules/drizzle-kit/index.cjs:40763:44)
at Socket.emit (node:events:515:28)
at addChunk (node:internal/streams/readable:545:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:495:3)
at Readable.push (node:internal/streams/readable:375:5)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
length: 169,
severity: 'ERROR',
code: '42804',
detail: undefined,
hint: 'You might need to specify "USING id::uuid".',
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'tablecmds.c',
line: '12332',
routine: 'ATPrepAlterColumnType'
}
No description
No description
7 Replies
gdalmau
gdalmau13mo ago
put the .defaultRandom() AFTER .primaryKey() At least that’s how I have it working in my code
tomri
tomriOP13mo ago
not woeking
Angelelz
Angelelz13mo ago
Your problem is that the id column already exists and is another type. Do you have data in that table?
tomri
tomriOP13mo ago
yeah, that was the issue, anyway thanks
Enginir Aerospes
need help with the same issue!
Angelelz
Angelelz7mo ago
Please paste your table definition and the error you saw
Want results from more Discord servers?
Add your server