© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
6 replies
mr_pablo

MySQL UUID as PK

I am unable to get a PK setup which has a default UUID value.

I have

logID: varchar('logID', { length: 48 }).default(sql`'UUID()'`).primaryKey(),
logID: varchar('logID', { length: 48 }).default(sql`'UUID()'`).primaryKey(),

in my table schema

But it creates a migration query that literally adds the literal string 'UUID()' in the field

CREATE TABLE `feedLogs` (
    `logID` varchar(48) NOT NULL DEFAULT 'UUID()',
    `feedType` varchar(10),
    CONSTRAINT `feedLogs_logID` PRIMARY KEY(`logID`)
);
CREATE TABLE `feedLogs` (
    `logID` varchar(48) NOT NULL DEFAULT 'UUID()',
    `feedType` varchar(10),
    CONSTRAINT `feedLogs_logID` PRIMARY KEY(`logID`)
);


but running this in MySQL directly, the table is created with a PK that does default to an actual UUID string value
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Can someone direct me to a UUID implementation as PK with Drizzle ORM?
Drizzle TeamDTDrizzle Team / help
2y ago
uuid missing in drizzle-orm/mysql-core?
Drizzle TeamDTDrizzle Team / help
3y ago
Composite PK
Drizzle TeamDTDrizzle Team / help
2y ago
Default UUID as text type
Drizzle TeamDTDrizzle Team / help
3y ago