© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•15mo ago•
1 reply
/home/leonl

Enum Type Creation

Having a small issue where when I run generate, my enum type is not being created, giving, an error when migrating:

This is at the top of the schema.

const roleEnum = pgEnum('role', ['user', 'admin']);

export const users = pgTable('user', {
    id: text()
        .primaryKey()
        .$defaultFn(() => crypto.randomUUID()),
    name: text(),
    email: text().unique(),
    emailVerified: timestamp({ mode: 'date' }),
    password: text(),
    image: text(),
    role: roleEnum().notNull().default('user'),
});
const roleEnum = pgEnum('role', ['user', 'admin']);

export const users = pgTable('user', {
    id: text()
        .primaryKey()
        .$defaultFn(() => crypto.randomUUID()),
    name: text(),
    email: text().unique(),
    emailVerified: timestamp({ mode: 'date' }),
    password: text(),
    image: text(),
    role: roleEnum().notNull().default('user'),
});


With the error on migrate being that role doesn't exist.

Do we just manually add the type definition in the sql or have I missed a step?
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

Enum type gets lost
Drizzle TeamDTDrizzle Team / help
3y ago
Casting column to enum type
Drizzle TeamDTDrizzle Team / help
2y ago
Enum error type ... does not exist
Drizzle TeamDTDrizzle Team / help
2y ago
Inserting into columns of type Enum
Drizzle TeamDTDrizzle Team / help
3y ago