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?
1 Reply
ionztorm
ionztormOP2w ago
well, it just randomly has started working. There's still no enum type definition in the sql migration file but the migrate worked and if I create a record in the dashboard, the role is limited to the enum options! weird! I changed nothing. I'll go sit in a corner and rock back and forth for a bit.
Want results from more Discord servers?
Add your server