© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•2y ago
fantasy

uuid becomes text in migration

In my schema i have a user table (based on auth.js requirements):
export const users = pgTable("user", {
    id: uuid("id").primaryKey().defaultRandom(),
    name: text("name"),
    email: text("email").notNull(),
    emailVerified: timestamp("emailVerified", { mode: "date" }),
    image: text("image"),
});
export const users = pgTable("user", {
    id: uuid("id").primaryKey().defaultRandom(),
    name: text("name"),
    email: text("email").notNull(),
    emailVerified: timestamp("emailVerified", { mode: "date" }),
    image: text("image"),
});


However in the resulting migration, the column is marked as text and is missing the
DEFAULT gen_random_uuid()
DEFAULT gen_random_uuid()
:
CREATE TABLE IF NOT EXISTS "user" (
    "id" text PRIMARY KEY NOT NULL,
...
CREATE TABLE IF NOT EXISTS "user" (
    "id" text PRIMARY KEY NOT NULL,
...

This does not happen for other tables, for example:
export const roles = pgTable("role", {
    id: uuid("id").primaryKey().defaultRandom(),
...
export const roles = pgTable("role", {
    id: uuid("id").primaryKey().defaultRandom(),
...

CREATE TABLE IF NOT EXISTS "role" (
    "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
...
CREATE TABLE IF NOT EXISTS "role" (
    "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
...


I'm using the latest drizzle-kit 0.21.1 version.
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

Default UUID as text type
Drizzle TeamDTDrizzle Team / help
3y ago
Can't insert uuid value in uuid foreign key
Drizzle TeamDTDrizzle Team / help
2y ago
Custom UUID
Drizzle TeamDTDrizzle Team / help
3y ago
Using BIN_TO_UUID / UUID_TO_BIN
Drizzle TeamDTDrizzle Team / help
3y ago