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(),

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`)
);


but running this in MySQL directly, the table is created with a PK that does default to an actual UUID string value
Was this page helpful?