Drizzle not creating enum

Hey guys, I am using drizzle in my project with postgres. I create a new enum(with pgenum) but the generate sql is missing the definition of the enum.
const status = pgEnum('status', [
'created',
'generating',
'generated',
'error',
]);
const status = pgEnum('status', [
'created',
'generating',
'generated',
'error',
]);
and using this as status: status().notNull().default('created') and here's the generated sql
CREATE TABLE "curriculums" (
"id" varchar PRIMARY KEY NOT NULL,
"user_id" varchar NOT NULL,
"language_id" varchar NOT NULL,
"created_at" varchar DEFAULT now() NOT NULL,
"status" "status" DEFAULT 'created' NOT NULL,
"reason" varchar DEFAULT '' NOT NULL,
"knowledge" varchar DEFAULT '' NOT NULL
);
CREATE TABLE "curriculums" (
"id" varchar PRIMARY KEY NOT NULL,
"user_id" varchar NOT NULL,
"language_id" varchar NOT NULL,
"created_at" varchar DEFAULT now() NOT NULL,
"status" "status" DEFAULT 'created' NOT NULL,
"reason" varchar DEFAULT '' NOT NULL,
"knowledge" varchar DEFAULT '' NOT NULL
);
there's no definition of enum
9 Replies
TOSL
TOSL4w ago
you have to export everything Drizzle doesn't know you created an enum because you didn't export it
Phantom
PhantomOP4w ago
I did export it
Mario564
Mario5644w ago
@Phantom Assuming you're already exporting the status enum, in what file is that enum present in and what's the schema path in your Drizzle config file?
TOSL
TOSL4w ago
Okay. What you added here just says const status so that was the quickest solution. If you have that in the actual file, then I don't think you actually have an issue. Drizzle would create the enum and then create the table. Judging from this:
"status" "status" DEFAULT 'created' NOT NULL,
"status" "status" DEFAULT 'created' NOT NULL,
It looks like Drizzle is making the enum as expected.
Phantom
PhantomOP4w ago
this is the column the sql file was missing the CREATE TYPE status AS ENUM I added that manually I'll submit a minimal reproduction tomorrow
mosess
mosess3w ago
this is my exact dilema, any permanent fix yet? i had to create the type manually in the migration file.
Phantom
PhantomOP3w ago
I gave up on drizzle and reverted back to prisma
mosess
mosess3w ago
damn, sad. i can't give up now. they need to fix this.
TOSL
TOSL3w ago
Phantom, didn't provide much to go on so helping is hard. Share your schema and maybe your config. Also share the output of drizzle generate

Did you find this page helpful?