drizzle-team / drizzle-team/drizzle-orm
[BUG]:set uuid to primarykey but can't set defaultRandom()
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### What version of `drizzle-orm` are you using?
0.28.6
### What version of `drizzle-kit` are you using?
0.19.13
### Describe the Bug
set uuid to primarykey but can't set defaultRandom()
export const address = pgTable('address', {
id: uuid('id').primaryKey().defaultRandom(),
name: varchar('name').notNull(),
phone: varchar('phone', { length: 12 }).notNull(),
address: text('address').notNull(),
createdAt: timestamp('created_at').defaultNow(),
updatedAt: timestamp('updated_at').default(sql`CURRENT_TIMESTAMP`),
user_id: uuid('user_id')
.references(() => user.id)
.notNull(),
});
drizzle-kit:
drizzle-kit push:pg --config=drizzle.config.ts
drizzle-kit: v0.19.13
drizzle-orm: v0.28.6
Custom config path was provided, using 'drizzle.config.ts'
Reading config file '/Users/vincent_pun/WebStormProjects/restaurant/backend/drizzle.config.ts'
error: function gen_random_uuid() does not exist
at Parser.parseErrorMessage (/Users/vincent_pun/WebStormProjects/restaurant/backend/node_modules/.pnpm/registry.npmmirror.com+drizzle-kit@0.19.13/node_modules/drizzle-kit/index.cjs:40722:98)
at Parser.handlePacket (/Users/vincent_pun/WebStormProjects/restaurant/backend/node_modules/.pnpm/registry.npmmirror.com+drizzle-kit@0.19.13/node_modules/drizzle-kit/index.cjs:40563:25)
at Parser.parse (/Users/vincent_pun/WebStormProjects/restaurant/backend/node_modules/.pnpm/registry.npmmirror.com+drizzle-kit@0.19.13/node_modules/drizzle-kit/index.cjs:40487:34)
at Socket. (/Users/vincent_pun/WebStormProjects/restaurant/backend/node_modules/.pnpm/registry.npmmirror.com+drizzle-kit@0.19.13/node_modules/drizzle-kit/index.cjs:40763:44)
at Socket.emit (node:events:513:28)
at addChunk (node:internal/streams/readable:324:12)
at readableAddChunk (node:internal/streams/readable:297:9)
at Readable.push (node:internal/streams/readable:234:10)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
length: 206,
severity: 'ERROR',
code: '42883',
detail: undefined,
hint: 'No function matches the given name and argument types. You might need to add explicit type casts.',
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'parse_func.c',
line: '516',
routine: 'ParseFuncOrColumn'
}
### Expected behavior
_No response_
### Environment & setup
_No response_
Contributor guide
Research direction
Reproduce the issue with drizzle-kit push:pg using drizzle-orm 0.28.6 and drizzle-kit 0.19.13, then inspect the generated SQL for defaultRandom() and gen_random_uuid(). Check how the PostgreSQL setup handles that function; done means the reported schema applies successfully or the missing prerequisite and expected behavior are clearly established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, typescript
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100