You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have verified that the bug I'm about to report hasn't been filed before.
What version of drizzle-orm are you using?
0.38.2
What version of drizzle-kit are you using?
0.30.1
Other packages
No response
Describe the Bug
1-Does not generate tables
2-just create a user schema and add an enum role that can be user or admin and run npx drizzle-kit generate
import { pgTable, serial, varchar, text, timestamp, pgEnum } from "drizzle-orm/pg-core";
const roleEnum = pgEnum("roles", ["client", "profissional"])
3- user table created
4- Postgres
5-It only happens when I work with node and express, in nextjs it works fine, (pg and neon )
6- I'm not using monorepo
7- I'm using javascript
8- using node
The text was updated successfully, but these errors were encountered:
Longer explanation:
I'm not sure I'm understanding you correctly.
When I copy the code you've provided the table is generated but without the enum resulting in error when running the actual migration on the database. (On postgres it is code: 42704 which means UNDEFINED OBJECT which refers to the line "roles" "roles" NOT NULL in the generated sql),
I've assumed this is the issue you have, and in order to make the enum "work", you have to export it from your schema as well:
After adding the export the generated SQL looks like:
CREATETYPE "public"."roles"AS ENUM('client', 'profissional');--> statement-breakpointCREATETABLE "users" (
"id"serialPRIMARY KEYNOT NULL,
"name"varchar(100) NOT NULL,
"email"varchar(100) NOT NULL,
"password_hash"varchar(255) NOT NULL,
"phone"varchar(15),
"address"text,
"roles""roles"NOT NULL,
"created_at"timestamp with time zone DEFAULT now(),
"updated_at"timestamp with time zone DEFAULT now(),
CONSTRAINT"bla_email_unique" UNIQUE("email")
);
Report hasn't been filed before.
What version of
drizzle-orm
are you using?0.38.2
What version of
drizzle-kit
are you using?0.30.1
Other packages
No response
Describe the Bug
1-Does not generate tables
2-just create a user schema and add an enum role that can be user or admin and run npx drizzle-kit generate
import { pgTable, serial, varchar, text, timestamp, pgEnum } from "drizzle-orm/pg-core";
const roleEnum = pgEnum("roles", ["client", "profissional"])
export const users = pgTable(
"users", // Nome da tabela
{
id: serial("id").primaryKey(),
name: varchar("name", { length: 100 }).notNull(),
email: varchar("email", { length: 100 }).notNull().unique(),
passwordHash: varchar("password_hash", { length: 255 }).notNull(),
phone: varchar("phone", { length: 15 }),
address: text("address"),
userType: roleEnum("roles").notNull(),
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(),
updatedAt: timestamp("updated_at", { withTimezone: true })
.defaultNow()
.$onUpdateFn(() => new Date()),
}
);
3- user table created
4- Postgres
5-It only happens when I work with node and express, in nextjs it works fine, (pg and neon )
6- I'm not using monorepo
7- I'm using javascript
8- using node
The text was updated successfully, but these errors were encountered: